I cant get socket connection outside the server box

David Mathews grnbriar at mindspring.com
Mon Jul 2 19:31:21 PDT 2007


Thanks. I have finally gotten an outside connection by hostname. IP  
doesn't work, but since I'm on DHCP for ip I'm just dropping that part.

I have most of the app running, except - Can you use two different  
ports at the same time?
I need the two programs to listen on a different port, since I need  
to wait on a signel back that the current job is finished.

As soon as I add a listener to a different port on the server, all  
the previously running socket code fails.
If I listen to the same port as I use to connect out on, everything  
works, but it means I can't have a client running on the server box  
as it won't let me run two listeners on the same port.

Is the single port a wxSockets limitation?
or is there a way to set that up?

I really need to be able to run a client on the server box, since the  
server does nothing 99% of the time. It is just handing out jobs to run.

Thanks,
David


On Jul 2, 2007, at 2:42 PM, Geoffrey McLean wrote:

> 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"
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>





More information about the wx-users mailing list