NETWORK PROGRAMMING IN JAVA USING SOCKETS
|
|
|
- Ariel Norman
- 9 years ago
- Views:
Transcription
1 NETWORK PROGRAMMING IN JAVA USING SOCKETS Prerna Malik, Poonam Rawat Student, Dronacharya College of Engineering, Gurgaon, India Abstract- Network programming refers to writing programs that could be processed across various devices which are connected to each other via a network. Network programming is similar to socket programming or Client-Server programming. It basically uses the Client Server model. In Client-Server programming there are two different programs or process, one which initiates communication called Client process and other who is waiting for communication to start called Server process. Sockets provide the communication mechanism between two computers. A socket is an endpoint of a two-way communication link between two programs running on the network. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. When the connection is made, the server creates a socket object on its end of the communication. The client and server can now communicate by writing to and reading from the socket. This paper represents information about Network programming using java. Network programming is an essential factor to perceive the implications of communication work across processes based on internet. In this we describe about the programming code involved in client-server communications and different types of sockets used in such communication model. I. INTRODUCTION The term network programming refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network. Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. When the connection is made, the server creates a socket object on its end of the communication. The client and server can now communicate by writing to and reading from the socket. The java.net package of the J2SE APIs contains a collection of classes and interfaces that provide the low-level communication details, allowing you to write programs that focus on solving the problem at hand. The java.net.socket class represents a socket, and the java.net.serversocket class provides a mechanism for the server program to listen for clients and establish connections with them. The java.net package supports two common network protocols: TCP: TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically over the Internet Protocol (IP), and is referred as TCP/IP. UDP: UDP stands for User Datagram Protocol, a connectionless protocol that allows for packets of data to be transmitted between applications. II. OVERVIEW OF SOCKET PROGRAMMING Sockets were developed in 1981 at the University of California, Berkeley. The project was sponsored by ARPA (Advanced Research Projects Agency) in Initially, in 1983, the sockets were referred as Berkeley Sockets. The main objective was the transport of TCP/IP software to UNIX. In 1986, AT&T introduced the Transport Layer Interface (TLI) with socket like functionality, which was more network independent. UNIX includes both TLI and Sockets after SVR4.[3] 2.1 Socket definition: A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes are used to represent IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1376
2 the connection between a client program and a server program. The java.net package provides two classes-- Socket and ServerSocket--that implement the client side of the connection and the server side of the connection, respectively. Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. When the connection is made, the server creates a socket object on its end of the communication. The client and server can now communicate by writing to and reading from the socket TCP sockets TCP Is a byte-stream During data packet transmission, no packetizing and addressing is required by application. Formatting has to be provided by application. Two or more successive data sends on the pipe connected to socket may be combined together by TCP in a single packet UDP sockets UDP is packet-oriented Information sent in packet format as needed by application. Every packet requires address information. Lightweight, no connection required. Overhead of adding destination address with each packet After the server is waiting, a client instantiates a Socket object, specifying the server name and port number to connect to. The constructor of the Socket class attempts to connect the client to the specified server and port number. If communication is established, the client now has a Socket object capable of communicating with the server. On the server side, the accept() method returns a reference to a new socket on the server that is connected to the client's socket. After the connections are established, communication can occur using I/O streams. Each socket has both an OutputStream and an InputStream. The client's OutputStream is connected to the server's InputStream, and the client's InputStream is connected to the server's OutputStream. TCP is a two-way communication protocol, so data can be sent across both streams at the same time. There are following useful classes providing complete set of methods to implement sockets. Workflow of a socket: 2.2 Steps for Establishing a TCP Connection between Two Computers Using Sockets: The following steps occur when establishing a TCP connection between two computers using sockets: The server instantiates a ServerSocket object, denoting which port number communication is to occur on. The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port. [10] IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1377
3 2.3. The classes, interfaces and Exceptions in socket programming Table 1: The classes in socket communication ContentHandler DatagramSocketImpl DatagramPacket DatagramSocket HttpURLConnection InetAddress MulticastSocket ServerSocket Socket SocketImpl URL URLEncoder URLStreamHandler URLConnection Table 2: The interfaces used in socket programming ContentHandlerFactory FileNameMap SocketImplFactory URLStreamHandlerFactory Table 3: Exceptions in socket programming BindException ConnectException MalformedURLException NoRouteToHostException ProtocolException SocketException UnknownHostException UnknownServiceException 2.4 ServerSocket Class Methods: Four constructors are contained in The ServerSocket class: 1. public ServerSocket(int port) throws IOException: Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by another application. 2. public ServerSocket(int port, int backlog) throws IOException: Similar to the previous constructor, the backlog parameter specifies how many incoming clients to store in a wait queue.[8] 3. public ServerSocket(int port, int backlog, InetAddress address) throws IOException: Similar to the previous constructor, the InetAddress parameter specifies the local IP address to bind to. The InetAddress is used for servers that may have multiple IP addresses, allowing the server to specify which of its IP addresses to accept client requests on.[7] 4. public ServerSocket() throws IOException: Creates an unbound server socket. When using this constructor, use the bind() method when you are ready to bind the server socket. If the ServerSocket constructor does not throw an exception, it means that your application has successfully bound to the specified port and is ready for client requests.[9] IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1378
4 2.5. Common methods of the ServerSocket class: 1. public int getlocalport(): Returns the port that the server socket is listening on. This method is useful if 0 is passed as the port number in a constructor. 2. public Socket accept() throws IOException: Waits for an incoming client. This method blocks until either a client connects to server on specified port or the socket times out assuming that the time-out value has been set by setsotimeout() method. Otherwise this method blocks indefinitely. 3. public void setsockettimeot(int timeout): Sets the time-out value for how long the server socket waits for a client during the accept(). 4. public void bind(socketaddress host, int backlog): Binds the socket to specified server and port in the SocketAddress object. It is used in case of no object constructor. When the ServerSocket invokes accept(), the method does not return until a client connects. After a client does connect, the ServerSocket creates a new Socket on an unspecified port and returns a reference to this new Socket. A TCP connection now exists between the client and server, and communication can begin. 2.6 Socket Class Methods: The java.net.socket class represents the socket that both the client and server use to communicate with each other. The client obtains a Socket object by instantiating one, whereas the server obtains a Socket object from the return value of the accept() method. The Socket class has five constructors that a client uses to connect to a server: 1. public Socket(String host, int port) throws UnknownHostException, IOException: This method attempts to connect to the specified server at the specified port. If this constructor does not throw an exception, the connection is successful and the client is connected to the server. 2. public Socket(InetAddress host, int port) throws IOException: This method is identical to the previous constructor, except that the host is denoted by an InetAddress object. 3. public Socket(String host, int port, InetAddress localaddress, int localport) throws IOException: Connects to the specified host and port, creating a socket on the local host at the specified address and port. 4. public Socket(InetAddress host, int port, InetAddress localaddress, int localport) throws IOException: This method is identical to the previous constructor, except that the host is denoted by an InetAddress object instead of a String 5. 5.public Socket(): Creates an unconnected socket. Use the connect() method to connect this socket to a server. When the Socket constructor returns, it does not simply instantiate a Socket object but it actually attempts to connect to the specified server and port. Some methods in the Socket class are listed here which can be invoked by both the client and server: 1. public void connect(socketaddress host, int timeout) throws IOException: This method connects the socket to the specified host. This method is needed only when you instantiated the Socket using the no-argument constructor. 2. public InetAddress getinetaddress(): This method returns the address of the other computer that this socket is connected to. 3. public int getport(): Returns the port the socket is bound to on the remote machine. 4. public int getlocalport(): Returns the port the socket is bound to on the local machine. 5. public SocketAddress getremotesocketaddress(): Returns the address of the remote socket. 6. public InputStream getinputstream() throws IOException:Returns the input stream of the socket. The input stream is connected to the output stream of the remote socket. 7. public OutputStream getoutputstream() throws IOException: Returns the output stream of the socket. The output stream is connected to the input stream of the remote socket. 8. public void close() throws IOException: Closes the socket, which makes this Socket IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1379
5 object no longer capable of connecting again to any server. 2.7 InetAddress Class Methods: This class represents an Internet Protocol (IP) address. Some methods which are required while doing socket programming: 1. static InetAddress getbyaddress(byte[] addr): Returns an InetAddress object given the raw IP address. 2. static InetAddress getbyaddress(string host, byte[] addr): Create an InetAddress based on the provided host name and IP address. 3. static InetAddress getbyname(string host): Determines the IP address of a host, given the host's name. 4. String gethostaddress(): Returns the IP address string in textual presentation. 5. String gethostname(): Gets the host name for this IP address. 6. static InetAddress InetAddress getlocalhost(): Returns the local host. 7. String tostring(): Converts this IP address to a String. III. TCP SOCKET PROGRAMMING In order to do communication over the TCP protocol, a connection must first be established between the pair of sockets. While one of the sockets listens for a connection request (server), the other asks for a connection (client). Once two sockets have been connected, they can be used to transmit data in both (or either one of the) directions Server Programming in Java A server program creates a specific type of socket that is used to listen for client requests (server socket), In the case of a connection request, the program creates a new socket through which it will exchange data with the client using input and output streams. The socket abstraction is very similar to the file concept that is, developers have to open a socket, perform I/O, and close it. The steps for creating a simple server program are: 1. Open the Server Socket: ServerSocket server = new ServerSocket( PORT ); 2. Wait for the Client Request: Socket client = server.accept(); Socket Programming Create I/O streams for communicating to the client DataInputStream is = new DataInputStream(client.getInputStream()); DataOutputStream os = new DataOutputStream(client.getOutputStream()); 4. Perform communication with client Receive from client: String line = is.readline(); Send to client: os.writebytes( Hello\n ); 5. Close socket: client.close(); IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1380
6 Program 1: // SimpleServer.java: A simple server program. import java.net.*; import java.io.*; public class SimpleServer { public static void main(string args[]) throws IOException { // Register service on port 1254 ServerSocket s = new ServerSocket(1254); Socket s1=s.accept(); // Wait and accept a connection // Get a communication stream associated with the socket OutputStream s1out = s1.getoutputstream(); DataOutputStream dos = new DataOutputStream (s1out); // Send a string! dos.writeutf( Hi there ); // Close the connection, but not the server socket dos.close(); s1out.close(); s1.close(); A simple Client Program in Java The steps for creating a simple client program are: 1. Create a Socket Object: Socket client = new Socket(server, port_id); 2. Create I/O streams for communicating with the server. is = new DataInputStream(client.getInputStream()); os = new DataOutputStream(client.getOutputStream()); 3. Perform I/O or communication with the server: Receive data from the server: String line = is.readline(); Send data to the server: os.writebytes( Hello\n ); 4. Close the socket when done: client.close(); IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1381
7 Program 2: // SimpleClient.java: A simple client program. import java.net.*; import java.io.*; public class SimpleClient { public static void main(string args[]) throws IOException { // Open your connection to a server, at port 1254 Socket s1 = new Socket( localhost,1254); // Get an input file handle from the socket and read the input InputStream s1in = s1.getinputstream(); DataInputStream dis = new DataInputStream(s1In); String st = new String (dis.readutf()); System.out.println(st); // When done, just close the connection and exit dis.close(); s1in.close(); s1.close(); IV. UDP SOCKET PROGRAMMING TCP guarantees the delivery of packets and preserves their order on destination. Sometimes these features are not required and since they do not come without performance costs, it would be better to use a lighter transport protocol. This kind of service is accomplished by the UDP protocol which conveys datagram packets. Datagram packets are used to implement a connectionless packet delivery service supported by the UDP protocol. Each message is transferred from source machine to destination based on information contained within that packet. That means, each packet needs to have destination address and each packet might be routed differently, and might arrive in any order. Packet delivery is not guaranteed. 4.1 Java supports datagram communication through the following classes: DatagramPacket DatagramSocket The class DatagramPacket contains several constructors that can be used for creating packet object. The key methods of DatagramPacket class are: 1. byte[] getdata(): Returns the data buffer. 2. int getlength(): Returns the length of the data to be sent or the length of the data received. IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1382
8 3. void setdata(byte[] buf): Sets the data buffer for this packet. 4. void setlength(int length): Sets the length for this packet The class DatagramSocket supports various methods that can be used for transmitting or receiving data over the network. The two key methods are: 1. void send(datagrampacket p): Sends a datagram packet from this socket. 2. void receive(datagrampacket p): Receives a datagram packet from this socket. 4.2 UDP server program A simple UDP server program that waits for client s requests and then accepts the message (datagram) and sends back the same message: IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1383
9 Program 3 // UDPServer.java: A simple UDP server program. import java.net.*; import java.io.*; public class UDPServer {354 Object-Oriented Programming with Java public static void main(string args[]){ DatagramSocket asocket = null; if (args.length < 1) { System.out.println( Usage: java UDPServer <Port Number> ); System.exit(1); try { int socket_no = Integer.valueOf(args[0]).intValue(); asocket = new DatagramSocket(socket_no); byte[] buffer = new byte[1000]; while(true) { DatagramPacket request = new DatagramPacket(buffer, buffer.length); asocket.receive(request); DatagramPacket reply = new DatagramPacket(request.getData(), request.getlength(),request.getaddress(), request.getport()); asocket.send(reply); catch (SocketException e) { System.out.println( Socket: + e.getmessage()); IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1384
10 catch (IOException e) { System.out.println( IO: + e.getmessage()); finally { if (asocket!= null) asocket.close(); 4.3 UDP client program: A corresponding client program for creating a datagram and then sending it to the above server and then accepting a response: IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1385
11 Program 4 // UDPClient.java: A simple UDP client program. import java.net.*; import java.io.*; public class UDPClient { public static void main(string args[]){ // args give message contents and server hostname DatagramSocket asocket = null; if (args.length < 3) { System.out.println( Usage: java UDPClient <message> <Host name> <Port number> ); System.exit(1); try { asocket = new DatagramSocket(); byte [] m = args[0].getbytes(); InetAddress ahost = InetAddress.getByName(args[1]); int serverport = Integer.valueOf(args[2]).intValue(); DatagramPacket request = new DatagramPacket(m, args[0].length(), ahost, serverport); asocket.send(request); byte[] buffer = new byte[1000]; DatagramPacket reply = new DatagramPacket(buffer, buffer.length); asocket.receive(reply); System.out.println( Reply: + new String(reply.getData())); catch (SocketException e) { System.out.println( Socket: + e.getmessage()); IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1386
12 catch (IOException e) { System.out.println( IO: + e.getmessage()); finally { if (asocket!= null) asocket.close(); V. CONCLUSIONS In this paper an attempt was made to investigate in to network programming using sockets. Socket programming is best suitable for communication between clients and server. There are several works done on socket programming ever since its advent. This is proved as Windows, Macintosh and UNIX provide interoperability with socket interface. Java is taking over socket programming however the portability can t be matched. Keeping all aspects of the paper we believe socket programming has yet to evolve in its types and ways it will perform in applications. All these will require the thought to have faster and reliable transactions between the server and clients. RESOURCES [1] J. F. Kurose and K. W Ross, Computer Networking- A Top-Down Approach featuring the Internet, 2nd Edition (Addison Wesley World Student Edition) [2] Q. Charatan and A. Kans, Java in two semesters, 2 nd edition McGraw Hills publication,2006 [3] Introduction to Sockets, web.njit.edu/~gblank/cis604/lectures/604sockets.ppt [4] Oracle.comhttp:// docs.oracle.com/cd/e / /6mb7bck68/index.html [5] H. Schildt, The Complete Reference, Seventh Edition, Chap. 27 [6] Tanenbaum, Computer Networks, Second edition [7] Author P. Burden, Socket Programming [8] Author G. McMillan, Socket Programming HOWTO [9] Socket Concepts: [10] g/sockets/ [11] Notes/Socket%20Programming.pdf [12] [13] ault.jpg IJIRT INTERNATONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY 1387
Socket Programming. A er learning the contents of this chapter, the reader will be able to:
Java Socket Programming This chapter presents key concepts of intercommunication between programs running on different computers in the network. It introduces elements of network programming and concepts
Socket Programming in Java
Socket Programming in Java Learning Objectives The InetAddress Class Using sockets TCP sockets Datagram Sockets Classes in java.net The core package java.net contains a number of classes that allow programmers
Transport layer protocols. Message destination: Socket +Port. Asynchronous vs. Synchronous. Operations of Request-Reply. Sockets
Transport layer protocols Interprocess communication Synchronous and asynchronous comm. Message destination Reliability Ordering Client Server Lecture 15: Operating Systems and Networks Behzad Bordbar
Network/Socket Programming in Java. Rajkumar Buyya
Network/Socket Programming in Java Rajkumar Buyya Elements of C-S Computing a client, a server, and network Client Request Result Network Server Client machine Server machine java.net Used to manage: URL
Java Network. Slides prepared by : Farzana Rahman
Java Network Programming 1 Important Java Packages java.net java.io java.rmi java.security java.lang TCP/IP networking I/O streams & utilities Remote Method Invocation Security policies Threading classes
Agenda. Network Programming and Java Sockets. Introduction. Internet Applications Serving Local and Remote Users
Programming and Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering University of Melbourne, Australia http://www.cs.mu.oz.au/~raj
Java Programming: Sockets in Java
Java Programming: Sockets in Java Manuel Oriol May 10, 2007 1 Introduction Network programming is probably one of the features that is most used in the current world. As soon as people want to send or
Network Communication
Network Communication Outline Sockets Datagrams TCP/IP Client-Server model OSI Model Sockets Endpoint for bidirectional communication between two machines. To connect with each other, each of the client
Socket Programming. Announcement. Lectures moved to
Announcement Lectures moved to 150 GSPP, public policy building, right opposite Cory Hall on Hearst. Effective Jan 31 i.e. next Tuesday Socket Programming Nikhil Shetty GSI, EECS122 Spring 2006 1 Outline
Application Development with TCP/IP. Brian S. Mitchell Drexel University
Application Development with TCP/IP Brian S. Mitchell Drexel University Agenda TCP/IP Application Development Environment Client/Server Computing with TCP/IP Sockets Port Numbers The TCP/IP Application
Lesson: All About Sockets
All About Sockets http://java.sun.com/docs/books/tutorial/networking/sockets/index.html Page 1 sur 1 The Java TM Tutorial Start of Tutorial > Start of Trail Trail: Custom Networking Lesson: All About Sockets
Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP
CP4044 Lecture 7 1 Networking Learning Outcomes To understand basic network terminology To be able to communicate using Telnet To be aware of some common network services To be able to implement client
Slides for Chapter 4: Interprocess Communication
Slides for Chapter 4: Interprocess Communication From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, Addison-Wesley 2012 Text extensions to slides David E.
Socket-based Network Communication in J2SE and J2ME
Socket-based Network Communication in J2SE and J2ME 1 C/C++ BSD Sockets in POSIX POSIX functions allow to access network connection in the same way as regular files: There are special functions for opening
Network Programming using sockets
Network Programming using sockets TCP/IP layers Layers Message Application Transport Internet Network interface Messages (UDP) or Streams (TCP) UDP or TCP packets IP datagrams Network-specific frames Underlying
Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Working as a group. Working in small gruops of 2-4 students. When you work as a group, you have to return only one home assignment per
CISC 4700 L01 Network & Client- Server Programming Spring 2016. Harold, Chapter 8: Sockets for Clients
CISC 4700 L01 Network & Client- Server Programming Spring 2016 Harold, Chapter 8: Sockets for Clients Datagram: Internet data packet Header: accounting info (e.g., address, port of source and dest) Payload:
SSC - Communication and Networking Java Socket Programming (II)
SSC - Communication and Networking Java Socket Programming (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics Multicast in Java User Datagram
Division of Informatics, University of Edinburgh
CS1Bh Lecture Note 20 Client/server computing A modern computing environment consists of not just one computer, but several. When designing such an arrangement of computers it might at first seem that
Sockets. Programação de Sockets em Java. Socket Abstractions. Camada de Transporte
Sockets Programação de Sockets em Java Server ports lients user space TP/UDP Socket API TP/UDP kernel space IP IP Ethernet Adapter Ethernet Adapter hardware SISTEMAS INFORMÁTIOS I, ENG. BIOMÉDIA SLIDES_10
Limi Kalita / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 5 (3), 2014, 4802-4807. Socket Programming
Socket Programming Limi Kalita M.Tech Student, Department of Computer Science and Engineering, Assam Down Town University, Guwahati, India. Abstract: The aim of the paper is to introduce sockets, its deployment
Network-based Applications. Pavani Diwanji David Brown JavaSoft
Network-based Applications Pavani Diwanji David Brown JavaSoft Networking in Java Introduction Datagrams, Multicast TCP: Socket, ServerSocket Issues, Gotchas URL, URLConnection Protocol Handlers Q & A
Data Communication & Networks G22.2262-001
Data Communication & Networks G22.2262-001 Session 10 - Main Theme Java Sockets Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences 1 Agenda
Assignment 4 Solutions
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Solutions Working as a pair Working in pairs. When you work as a pair you have to return only one home assignment per pair on a round.
NETWORKING FEATURES OF THE JAVA PROGRAMMING LANGUAGE
50-20-44 DATA COMMUNICATIONS MANAGEMENT NETWORKING FEATURES OF THE JAVA PROGRAMMING LANGUAGE John P. Slone INSIDE Java s Target Environment, Networking Basics, Java Networking Primitives, Connection-Oriented
Java Network Programming. The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol).
Java Network Programming The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol). The DatagramSocket class uses UDP (connectionless protocol). The java.net.socket
The difference between TCP/IP, UDP/IP and Multicast sockets. How servers and clients communicate over sockets
Network Programming Topics in this section include: What a socket is What you can do with a socket The difference between TCP/IP, UDP/IP and Multicast sockets How servers and clients communicate over sockets
String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.
164 CHAPTER 2 APPLICATION LAYER connection requests, as done in TCPServer.java. If multiple clients access this application, they will all send their packets into this single door, serversocket. String
Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1
Introduction to Java Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233 ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1 What Is a Socket? A socket is one end-point of a two-way
Creating a Simple, Multithreaded Chat System with Java
Creating a Simple, Multithreaded Chat System with Java Introduction by George Crawford III In this edition of Objective Viewpoint, you will learn how to develop a simple chat system. The program will demonstrate
Abstract Stream Socket Service
COM 362 Computer Networks I Lec 2: Applicatin Layer: TCP/UDP Socket Programming 1. Principles of Networks Applications 2. TCP Socket Programming 3. UDP Socket Programming Prof. Dr. Halûk Gümüşkaya [email protected]
Communicating with a Barco projector over network. Technical note
Communicating with a Barco projector over network Technical note MED20080612/00 12/06/2008 Barco nv Media & Entertainment Division Noordlaan 5, B-8520 Kuurne Phone: +32 56.36.89.70 Fax: +32 56.36.883.86
Socket programming. Complement for the programming assignment INFO-0010
Socket programming Complement for the programming assignment INFO-0010 Outline Socket definition Briefing on the Socket API A simple example in Java Multi-threading and Synchronization HTTP protocol Debugging
Abhijit A. Sawant, Dr. B. B. Meshram Department of Computer Technology, Veermata Jijabai Technological Institute
Network programming in Java using Socket Abhijit A. Sawant, Dr. B. B. Meshram Department of Computer Technology, Veermata Jijabai Technological Institute Abstract This paper describes about Network programming
Preface. Intended Audience
Preface For years, college courses in computer networking were taught with little or no hands on experience. For various reasons, including some good ones, instructors approached the principles of computer
Socket programming. Socket Programming. Languages and Platforms. Sockets. Rohan Murty Hitesh Ballani. Last Modified: 2/8/2004 8:30:45 AM
Socket Programming Rohan Murty Hitesh Ballani Last Modified: 2/8/2004 8:30:45 AM Slides adapted from Prof. Matthews slides from 2003SP Socket programming Goal: learn how to build client/server application
CHAPTER 6. Transmission Control Protocol. 6.1 Overview
Reilly06.qxd 3/1/02 1:33 PM Page 141 CHAPTER 6 Transmission Control Protocol The Transmission Control Protocol (TCP) is a stream-based method of network communication that is far different from any discussed
Session NM059. TCP/IP Programming on VMS. Geoff Bryant Process Software
Session NM059 TCP/IP Programming on VMS Geoff Bryant Process Software Course Roadmap Slide 160 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server
Package java.net. Interfaces. Classes. Exceptions. Package java.net Page 1 of 1. All Packages
Package java.net Page 1 of 1 Package java.net All Packages Interfaces ContentHandlerFactory FileMap SocketImplFactory URLStreamHandlerFactory Classes ContentHandler DatagramPacket DatagramSocket DatagramSocketImpl
DNS: Domain Names. DNS: Domain Name System. DNS: Root name servers. DNS name servers
DNS: Domain Name System DNS: Domain Names People: many identifiers: SSN, name, Passport # Internet hosts, routers: Always: IP address (32 bit) - used for addressing datagrams Often: name, e.g., nifc14.wsu.edu
ELEN 602: Computer Communications and Networking. Socket Programming Basics
1 ELEN 602: Computer Communications and Networking Socket Programming Basics A. Introduction In the classic client-server model, the client sends out requests to the server, and the server does some processing
AVRO - SERIALIZATION
http://www.tutorialspoint.com/avro/avro_serialization.htm AVRO - SERIALIZATION Copyright tutorialspoint.com What is Serialization? Serialization is the process of translating data structures or objects
Building a Multi-Threaded Web Server
Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous
TP1 : Correction. Rappels : Stream, Thread et Socket TCP
Université Paris 7 M1 II Protocoles réseaux TP1 : Correction Rappels : Stream, Thread et Socket TCP Tous les programmes seront écrits en Java. 1. (a) Ecrire une application qui lit des chaines au clavier
Chapter 11. User Datagram Protocol (UDP)
Chapter 11 User Datagram Protocol (UDP) The McGraw-Hill Companies, Inc., 2000 1 CONTENTS PROCESS-TO-PROCESS COMMUNICATION USER DATAGRAM CHECKSUM UDP OPERATION USE OF UDP UDP PACKAGE The McGraw-Hill Companies,
! "# $%&'( ) * ).) "%&' 1* ( %&' ! "%&'2 (! ""$ 1! ""3($
! "# $%&'( ) * +,'-( ).) /"0'" 1 %&' 1* ( %&' "%&'! "%&'2 (! ""$ 1! ""3($ 2 ', '%&' 2 , 3, 4( 4 %&'( 2(! ""$ -5%&'* -2%&'(* ) * %&' 2! ""$ -*! " 4 , - %&' 3( #5! " 5, '56! "* * 4(%&'(! ""$ 3(#! " 42/7'89.:&!
WRITING DATA TO A BINARY FILE
WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.
Corso di Reti di Calcolatori. java.net.inetaddress
Corso di Reti di Calcolatori UNICAL Facoltà di Ingegneria a.a. 2002/2003 Esercitazione sul networking in Java (1 a parte) [email protected] 1 java.net.inetaddress static InetAddress getbyname(string
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking
TITLE NETWORK PROGRAMMING (SECURED CLIENT-SERVER CHAT APPLICATION) A PROJECT REPORT PRESENTED ACHILE UGBEDE JOHN CE/2007/165
TITLE NETWORK PROGRAMMING (SECURED CLIENT-SERVER CHAT APPLICATION) A PROJECT REPORT PRESENTED BY ACHILE UGBEDE JOHN CE/2007/165 TO THE DEPARTMENT OF COMPUTER ENGINEERING IN FACULTY OF ENGINEERING CARITAS
Java Fundamental Classes Reference
Java Fundamental Classes Reference Mark Grand and Jonathan Knudsen O'REILLY Cambridge Köln Paris Sebastopol Tokyo v Table of Contents Preface xv 1. Introduction 1 1.1 The java.lang Package 2 1.2 The java.lang.reflect
An Android-based Instant Message Application
An Android-based Instant Message Application Qi Lai, Mao Zheng and Tom Gendreau Department of Computer Science University of Wisconsin - La Crosse La Crosse, WI 54601 [email protected] Abstract One of the
JAVA Program For Processing SMS Messages
JAVA Program For Processing SMS Messages Krishna Akkulu The paper describes the Java program implemented for the MultiModem GPRS wireless modem. The MultiModem offers standards-based quad-band GSM/GPRS
Intranet, Extranet, Firewall
Indian Institute of Technology Kharagpur Intranet, Extranet, Firewall Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 31: Intranet, Extranet, Firewall On completion,
Network Programming TDC 561
Network Programming TDC 561 Lecture # 1 Dr. Ehab S. Al-Shaer School of Computer Science & Telecommunication DePaul University Chicago, IL 1 Network Programming Goals of this Course: Studying, evaluating
Operating Systems Design 16. Networking: Sockets
Operating Systems Design 16. Networking: Sockets Paul Krzyzanowski [email protected] 1 Sockets IP lets us send data between machines TCP & UDP are transport layer protocols Contain port number to identify
Transparent Redirection of Network Sockets 1
Transparent Redirection of Network Sockets Timothy S. Mitrovich, Kenneth M. Ford, and Niranjan Suri Institute for Human & Machine Cognition University of West Florida {tmitrovi,kford,[email protected].
Advanced Network Programming Lab using Java. Angelos Stavrou
Advanced Network Programming Lab using Java Angelos Stavrou Table of Contents A simple Java Client...3 A simple Java Server...4 An advanced Java Client...5 An advanced Java Server...8 A Multi-threaded
Introduction to Socket Programming Part I : TCP Clients, Servers; Host information
Introduction to Socket Programming Part I : TCP Clients, Servers; Host information Keywords: sockets, client-server, network programming-socket functions, OSI layering, byte-ordering Outline: 1.) Introduction
Chapter 02 Networking in Java
Chapter 02 Networking in Java Lectures allotted: 08 Marks Given: 16 Contents: 2.1 Basics Socket overview, client/server, reserved sockets, proxy servers, internet addressing. 2.2 Java & the Net: The networking
Tutorial on Socket Programming
Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Seyed Hossein Mortazavi (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client- server
Socket = an interface connection between two (dissimilar) pipes. OS provides this API to connect applications to networks. home.comcast.
Interprocess communication (Part 2) For an application to send something out as a message, it must arrange its OS to receive its input. The OS is then sends it out either as a UDP datagram on the transport
When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer
Firewall Issues Firewalls are inevitably encountered by any networked enterprise application that has to operate beyond the sheltering confines of an Intranet Typically, firewalls block all network traffic,
Socket Programming in C/C++
September 24, 2004 Contact Info Mani Radhakrishnan Office 4224 SEL email mradhakr @ cs. uic. edu Office Hours Tuesday 1-4 PM Introduction Sockets are a protocol independent method of creating a connection
Objectives of Lecture. Network Architecture. Protocols. Contents
Objectives of Lecture Network Architecture Show how network architecture can be understood using a layered approach. Introduce the OSI seven layer reference model. Introduce the concepts of internetworking
Mail User Agent Project
Mail User Agent Project Tom Kelliher, CS 325 100 points, due May 4, 2011 Introduction (From Kurose & Ross, 4th ed.) In this project you will implement a mail user agent (MUA) that sends mail to other users.
Socket Programming. Request. Reply. Figure 1. Client-Server paradigm
Socket Programming 1. Introduction In the classic client-server model, the client sends out requests to the server, and the server does some processing with the request(s) received, and returns a reply
IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP
CSCE 515: Computer Network Programming TCP/IP IP Network Layer Wenyuan Xu Department of Computer Science and Engineering University of South Carolina IP Datagrams IP is the network layer packet delivery
ICT SEcurity BASICS. Course: Software Defined Radio. Angelo Liguori. SP4TE lab. [email protected]
Course: Software Defined Radio ICT SEcurity BASICS Angelo Liguori [email protected] SP4TE lab 1 Simple Timing Covert Channel Unintended information about data gets leaked through observing the
Domain Name System (DNS) Omer F. Rana. Networks and Data Communications 1
Domain Name System (DNS) Omer F. Rana Networks and Data Communications 1 What is a DNS Each institution on the internet has a host that runs a process called a Domain Name Server (also DNS!) It is not
Building a Java chat server
Building a Java chat server Presented by developerworks, your source for great tutorials Table of Contents If you're viewing this document online, you can click any of the topics below to link directly
Application Architecture
A Course on Internetworking & Network-based Applications CS 6/75995 Internet-based Applications & Systems Design Kent State University Dept. of Science LECT-2 LECT-02, S-1 2 Application Architecture Today
Transparent Redirection of Network Sockets 1
Transparent Redirection of Network Sockets 1 Timothy S. Mitrovich, Kenneth M. Ford, and Niranjan Suri Institute for Human & Machine Cognition University of West Florida {tmitrovi,kford,nsuri}@ai.uwf.edu
Socket Programming. Srinidhi Varadarajan
Socket Programming Srinidhi Varadarajan Client-server paradigm Client: initiates contact with server ( speaks first ) typically requests service from server, for Web, client is implemented in browser;
Manual. Programmer's Guide for Java API
2013-02-01 1 (15) Programmer's Guide for Java API Description This document describes how to develop Content Gateway services with Java API. TS1209243890 1.0 Company information TeliaSonera Finland Oyj
Introduction to Socket programming using C
Introduction to Socket programming using C Goal: learn how to build client/server application that communicate using sockets Vinay Narasimhamurthy [email protected] CLIENT SERVER MODEL Sockets are
Computer Networks/DV2 Lab
Computer Networks/DV2 Lab Room: BB 219 Additional Information: http://ti.uni-due.de/ti/en/education/teaching/ss13/netlab Equipment for each group: - 1 Server computer (OS: Windows Server 2008 Standard)
Lab 4: Socket Programming: netcat part
Lab 4: Socket Programming: netcat part Overview The goal of this lab is to familiarize yourself with application level programming with sockets, specifically stream or TCP sockets, by implementing a client/server
transmission media and network topologies client/server architecture layers, protocols, and sockets
Network Programming 1 Computer Networks transmission media and network topologies client/server architecture layers, protocols, and sockets 2 Network Programming a simple client/server interaction the
Remote Method Invocation
Remote Method Invocation The network is the computer Consider the following program organization: method call SomeClass AnotherClass returned object computer 1 computer 2 If the network is the computer,
Transport Layer Protocols
Transport Layer Protocols Version. Transport layer performs two main tasks for the application layer by using the network layer. It provides end to end communication between two applications, and implements
Rappels programma,on réseau Java- suite. C. Delporte M2- Internet Rappel Java 1
Rappels programma,on réseau Java- suite C. Delporte M2- Internet Rappel Java 1 Socket programming Two socket types for two transport services: UDP: unreliable datagram TCP: reliable, byte stream-oriented
Network Programming. Writing network and internet applications.
Network Programming Writing network and internet applications. Overview > Network programming basics > Sockets > The TCP Server Framework > The Reactor Framework > High Level Protocols: HTTP, FTP and E-Mail
What is an I/O Stream?
Java I/O Stream 1 Topics What is an I/O stream? Types of Streams Stream class hierarchy Control flow of an I/O operation using Streams Byte streams Character streams Buffered streams Standard I/O streams
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Lectures on distributed systems: Client-server communication. Paul Krzyzanowski
Lectures on distributed systems: Client-server communication Paul Krzyzanowski Everything lives, moves, everything corresponds; the magnetic rays, emanating either from myself or from others, cross the
Report of the case study in Sistemi Distribuiti A simple Java RMI application
Report of the case study in Sistemi Distribuiti A simple Java RMI application Academic year 2012/13 Vessio Gennaro Marzulli Giovanni Abstract In the ambit of distributed systems a key-role is played by
Chapter 3. Internet Applications and Network Programming
Chapter 3 Internet Applications and Network Programming 1 Introduction The Internet offers users a rich diversity of services none of the services is part of the underlying communication infrastructure
Computer Networks UDP and TCP
Computer Networks UDP and TCP Saad Mneimneh Computer Science Hunter College of CUNY New York I m a system programmer specializing in TCP/IP communication protocol on UNIX systems. How can I explain a thing
Generalised Socket Addresses for Unix Squeak 3.9 11
Generalised Socket Addresses for Unix Squeak 3.9 11 Ian Piumarta 2007 06 08 This document describes several new SocketPlugin primitives that allow IPv6 (and arbitrary future other) address formats to be
An Introduction to Network Programming with Java
An Introduction to Network Programming with Java Jan Graba An Introduction to Network Programming with Java Jan Graba, BA, PGCE, MSc Faculty of ACES Sheffield Hallam University UK British Library Cataloguing
The POSIX Socket API
The POSIX Giovanni Agosta Piattaforme Software per la Rete Modulo 2 G. Agosta The POSIX Outline Sockets & TCP Connections 1 Sockets & TCP Connections 2 3 4 G. Agosta The POSIX TCP Connections Preliminaries
Serializing Data with Protocol Buffers. Vinicius Vielmo Cogo Smalltalks, DI, FC/UL. February 12, 2014.
Serializing Data with Protocol Buffers Vinicius Vielmo Cogo Smalltalks, DI, FC/UL. February 12, 2014. Problem statement App2 App1 Storage 2 / 19 Problem statement App2 App1 Correct object Efficient (time
CPS221 Lecture: Layered Network Architecture
CPS221 Lecture: Layered Network Architecture Objectives last revised 9/10/12 1. To discuss the OSI layered architecture model 2. To discuss the specific implementation of this model in TCP/IP Materials:
TCP/IP - Socket Programming
TCP/IP - Socket Programming [email protected] Jim Binkley 1 sockets - overview sockets simple client - server model look at tcpclient/tcpserver.c look at udpclient/udpserver.c tcp/udp contrasts normal master/slave
