HI
i've made a chat server which works in the following way :-
1) The server runs on a specific port on aaa.com
2) The client connects to the server. The server returns the port and IP of the connected client to the client and also stores the ip and the port of this client in the database. This is because the client now starts listning for connections(just one ) on that specific port and on the specific IP.
At this stage the link between the client and server closes and the client is now ready to accept just one connection.
3) There is a third interface( i call it external client) through which the actual chatting takes place between the external client and the client ( which is now waiting for the external client to connect to it ). When the client gets connected its ip and port get stored into the database So when this third interface( external client) connects to the database it gets the ip and port of the connected clients which are now listening on specific port ( the port which the actual server retrieves and returns it to the client for it to listen on that port) .
Everything works fine on LAN (locally ) but on the internet it doesn't seem to work .
The prob lies with the connection which the extenal client tries to make to the client which is listening on a specific port ( which is returned by the actual server after retrieving it).
The idea is that the clients which connects to the actual server becomes small servers too so that they can listen for incomming connections(just one for each) and start a conversation.
One more thing . I,am tryig to
test this application on the same machine.That is my client ( which connects to the actual server) and the third interface ( external client ) are on the same machine . My external client tries to make a socket on the same IP on which it is running . Could that be a prob . Does a socket has to connect to the remote connection always ? . If yes then my prob could be that i,am running the external client and the client on the same machine.
One last thing . when the client connects to the server, the server returns the port by retriving it from the socket object (by using the accept() ) which is different from the the local port of the client . Locally the client( which also listens for connections) listens on the port given by the server and not the local port and in any case both the local port and the port returned by the server are the same but this is not the case when connecting to the internet.
And yes , the client which connects to the server which also becomes a small server listening for connections starts listening but the the third interface( the external client) is not able to make a Socket connection to the listening client( which is not acting as a small server).
Should i make the client listen on its local port or the port which is returned by the server ( retrieving the port through the Socket obect when the server accepts new connections )
Any suggestions ?
I hope i,am clear enough
Please help me guys. This is urgent
Thanks in advance
[ July 10, 2003: Message edited by: raghav mathur ]