![java telnet server java telnet server](https://cdn.osxdaily.com/wp-content/uploads/2009/12/telnet-working-macos-610x389.jpg)
![java telnet server java telnet server](http://4.bp.blogspot.com/-9QYRt7N0yss/UOXImrBdtfI/AAAAAAAAAKQ/sWQw_skL6QA/s1600/ThreadPool.gif)
S.connect(new InetSocketAddress(host, 80)) Public static void main(String args) throws IOException Quick example //java socket client example Now that we have the ip address of the remote host/system, we can connect to ip on a certain 'port' using the connect function. Here we used the ip address of as a sample. So you need to know the IP address of the remote server you are connecting to. So we need 2 things, IP address and port number to connect to. We connect to a remote server on a certain port number. But what next ? Next we shall try to connect to some server using this socket. Ok, so you have created a socket successfully.
![java telnet server java telnet server](https://i.stack.imgur.com/Qf06y.png)
UDP sockets in java are created using the class DatagramSocket, and we shall look into this in another article. The socket class is actually a TCP socket, although its not specified (like its done in C or python for example).Īlso, it is a "client socket" since it can be used only to make socket clients and not servers. The above creates a socket object that can be used for other operations like connecting and sending data. This first thing to do is create a socket. This tutorial assumes that you already have a basic knowledge of java and can compile and run java programs. In general any network communication goes through a socket. Same with any chat client like gtalk or skype. To summarise the basics, sockets are the fundamental "things" behind any kind of network communications done by your computer.įor example when you type in your web browser, it opens a socket and connects to to fetch the page and show it to you.