I cant get socket connection outside the server box

Geoffrey McLean geoff at mcleanresearch.com
Mon Jul 2 11:42:02 PDT 2007


On Saturday 30 June 2007 19:58, David Mathews wrote:
> How do I get a socket connection to another machine on the network?
> Currently, my server and client programs talk fine on the same box,
> but the external ones can not be reached.
> Using just the local machine name for the local box, which works
> fine, but neither name or ip work for remote boxes.
> I'm using machine Host Name (as comes back from wxaddress when a
> listener is established) and direct ip (in dot format).
> Both fail.
>
> What is missing to make an external socket connection?
> There is no firewall on either machine. They are on a home network
> with DHCP.
>
>
> wxIPV4address address;
> address.Hostname(machines[i].name);
> if(machines[i].ip[0] != 0) address.Hostname(machines[i].ip);  //
> added to test direct ip which I want to avoid
>
> address.Service(50667);
> wxSocketClient* client = new wxSocketClient();
>
> client->SetEventHandler(*this,SOCKET_ID);
> client->SetNotify(wxSOCKET_CONNECTION_FLAG|
> 	wxSOCKET_INPUT_FLAG|wxSOCKET_LOST_FLAG);
> client->Notify(true);
> client->Connect(address,false);
>
> I get only socket Lost for external addresses.
>
> Thanks,
> David


David - After the Connect this is what I have in my code which has always 
worked.  Perhaps you are not waiting for the connection to be made?

slog is my debugging file.


if (!my_socket->WaitOnConnect(10))wxMessageBox(wxT("Wait On Connect failed"), 
wxT("Alert!"));

	if (my_socket->IsConnected()) {
		fprintf(slog,"connected OK\n");
	} else {
 		my_socket->Close();
		fprintf(slog,"NOT connected\n");
		wxMessageBox(wxT("Cannot connect to Naval Engagement!"), wxT("Alert!"));
		exit(1);
	}

--------------------

Good luck!
-- 
Geoffrey McLean
McLean Research Associates

"To be good is not enough when you dream of being great"




More information about the wx-users mailing list