FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Getpeername() question
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Getpeername() question
Posted: Mon May 02, 2016 09:47 AM
The Getpeername() from FW accept a number as parameter. I use the Harbour-functions with inet*
Code (fw): Select all Collapse
pSocket := INetDGramBind( nPort , , .T. , cIP_M
and these are using a pointer for the open socket. In which way i convert from pointer to number to use FW-function. Or is there a Harbour-getpeername() with pointer as parameter?
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Getpeername() question
Posted: Mon May 02, 2016 10:17 AM
Günther,

> In which way i convert from pointer to number to use FW-function

PHB_SOCKET_STRUCT socket = HB_PARSOCKET( 1 );

it seems as socket->sd is the standard socket that FWH expects
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Getpeername() question
Posted: Mon May 02, 2016 08:07 PM

Antonio, thanks! I would use getpeername() to check if the connection is at the moment online. But in a datagram-socket gives the function not the current state but rather the ip from creation from the socket.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Getpeername() question
Posted: Tue May 03, 2016 07:09 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Getpeername() question
Posted: Tue May 03, 2016 07:12 AM
This is also interesting:

http://stackoverflow.com/questions/15778404/programmatically-check-whether-my-machine-has-internet-access-or-not

Code (fw): Select all Collapse
#include <iostream>
#include <windows.h> 
#include <wininet.h>
using namespace std;

int main(){

if(InternetCheckConnection(L"http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0))
{
        cout << "connected to internet";
}

return 0;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Getpeername() question
Posted: Tue May 03, 2016 08:08 PM

Thanks Antonio!
In my case with a multicast-socket i only receive messages over the local LAN. This messages comes from time to time. The manufacturer from the hardware says to me, that all maximal 10 seconds the message is refreshed. So i wait maximal this 10 seconds and when no message received in this time i show the message: OFFLINE. This is for me enough information for the user.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Getpeername() question
Posted: Wed May 04, 2016 08:33 AM

very good

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion