Programming with sockets:
Earlier we introduced the notion of a socket as a software mechanism that allows the transfer of data between programs. A socket is a logical idea of a connection to a host on the internet, and each socket is unique since it consists of an IP address and a port number.
Sockets on the client
The class Socket allows us to create sockets on the client system. The most common Socket constructor has the form:
Socket(String, int)
This creates a Socket object that allows communication with the computer, which has the address given by the first argument, using the port given by the second argument. For example, consider the following code:
Socket sock = new Socket("catalogue.acme.co.uk", 4000);
This creates a Socket object to link to port 4000 on the catalogue computer associated with the domain acme.co.uk. You can also use numeric IP addressing (dotted quad notation) for this address, as follows:
Socket sock = new Socket("199.200.34.123", 4000);
Communication between clients and a server is achieved by input/output streams. Each socket has an associated input stream and output stream - the methods getInputStream and getOutputStream give access to these streams. For example:
Socket sock = new Socket("catalogue.acme.co.uk", 4000); InputStream is = sock.getInputStream( );
OutputStream os = sock.getOutputStream( );
...
These streams can then be used to send and receive data, using a similar approach to writing and reading files.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Programming with sockets homework and assignments? Live Programming with sockets experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Programming with sockets homework help, java assignment help and Programming with sockets projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours