Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to remote system through socket

Tags:

java

sockets

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..

like image 381
Jinith Avatar asked Feb 07 '11 14:02

Jinith


People also ask

What is connect in socket?

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().

What is remote socket address?

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.

What is asynchronous socket connection?

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.


1 Answers

http://www.oracle.com/technetwork/java/socket-140484.html provides both server and client examples of connecting to a socket.

like image 136
William Avatar answered Nov 02 '22 20:11

William