Category : "Java"

Socket Programming in Java

Udp socket programming in Java

Datagram sockets UDP sockets can be used in java with the DatagramSocket class. Server Let code a simple udp server that listens on a certain port number. /** Java ECHO server with UDP sockets example Silver Moon (m00n.silv3r@gmail.com) */ import java.io.*; import java.net.*; public class udp_server { public static void main(String args) { DatagramSocket sock = null; try { //1. creating a server socket, parameter is local port number sock = new DatagramSocket(7777); //buffer to receive incoming data byte buffer ...

Java socket programming tutorial

Socket programming in Java This is a quick guide/tutorial to learning socket programming in Java. The Socket class is documented at http://docs.oracle.com/javase/1.4.2/docs/api/java/net/Socket.html To summarise the basics, sockets are the fundamental "things" behind any kind of network communications done by your computer. For example when you type www.google.com in your web browser, it opens a socket and connects to google.com to fetch the page ...