Thursday, May 5, 2011

Tutorial Asynchronous Socket Programming using .NET (For Server)

The following example program creates a server that receives connection requests from clients. The server is built with an asynchronous socket, so execution of the server application is not suspended while it waits for a connection from a client. The application receives a string from the client, displays the string on the console, and then echoes the string back to the client. The string from the client must contain the string "" to signal the end of the message.


Code For VB

Thursday, April 21, 2011

Tutorial Asynchronous Socket Programming using .NET (For Client)

The following example program creates a client that connects to a server. The client is built with an asynchronous socket, so execution of the client application is not suspended while the server returns a response. The application sends a string to the server and then displays the string returned by the server on the console.

Tutorial Synchronous Socket Programming using JAVA (For Server)

When you have setup code for client application, after a connection is established, a server application uses the same kind of Socket object for its side of the communications. However, to accept a connection from a client, it must first create a ServerSocket, bound to the correct port. Let's recreate the previous conversation from the server's point of view:



Tutorial Synchronous Socket Programming using JAVA (For Client)

A client application opens a connection to a server by constructing a Socket that specifies the hostname and port number of the desired server:

try {
Socket sock = new Socket("wupost.wustl.edu", 25);
} catch ( UnknownHostException e ) {
System.out.println("Can't find host.");
} catch ( IOException e ) {
System.out.println("Error connecting to host.");
}

Tutorial Synchronous Socket Programming using .NET (For Server)

The following example program creates a server that receives connection requests from clients. The server is built with a synchronous socket, so execution of the server application is suspended while it waits for a connection from a client. The application receives a string from the client, displays the string on the console, and then echoes the string back to the client. The string from the client must contain the string "<EOF>" to signal the end of the message.

Wednesday, April 20, 2011

Tutorial Synchronous Socket Programming using .NET (For Client)

The following example program creates a client that connects to a server. The client is built with a synchronous socket, so execution of the client application is suspended until the server returns a response. The application sends a string to the server and then displays the string returned by the server on the console.

CODE FOR VB
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Basic Knowledge/Tutorial Programming About Socket in JAVA

The network is the soul of Java. Most of what is interesting about Java centers around the potential for dynamic, networked applications. As Java's networking APIs have matured, Java has also become the language of choice for implementing traditional client-server applications and services.

The classes of java.net fall into two general categories: the Sockets API for working with low-level Internet protocols and higher-level, web-oriented APIs that work with uniform resource locators (URLs). Figure 1 shows the java.net package.

Basic Knowledge/Tutorial Programming About Socket in .NET

The Socket class provides a rich set of methods and properties for network communications. The Socket class allows you to perform both synchronous and asynchronous data transfer using any of the communication protocols listed in the ProtocolType enumeration.

The Socket class follows the .NET Framework naming pattern for asynchronous methods. For example, the synchronous Receive method corresponds to the asynchronous BeginReceive and EndReceive methods.