Am trying to connect to a remote system which is not in the same local area as mine through java sockets, can anyone share some sample code or docs to do so.
I have created a server socket and is listening for connection at a port.how can i connect to that socket from my client program that is not in the same local area network as the server.
Thanks in advance..
The connect() call on a stream socket is used by the client application to establish a connection to a server. The server must have a passive open pending. A server that is using sockets must successfully call bind() and listen() before a connection can be accepted by the server with accept().
Socket addressesAn application can communicate with a remote process by exchanging data with TCP/IP by knowing the combination of protocol type, IP address, and port number. This combination is often known as a socket address. It is the network-facing access handle to the network socket.
In an asynchronous socket, you CAN do other stuff while waiting for the client to send data to you, so now you CAN have multiple clients connecting to you. Synchronous uses a function like receive() which blocks until it gets a message. Asynchronous has beginReceive() endReceive() or similar functions.
http://www.oracle.com/technetwork/java/socket-140484.html provides both server and client examples of connecting to a socket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With