View Single Post
Old 04-24-2012, 06:00 AM   #7 (permalink)
Ojasviharsola
New Member
 
Join Date: Apr 2012
Location: Indore
Model: 9700
PIN: N/A
Carrier: Airtel
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post Re: How to Read from a socket ??

Code Snippet

public void run() {

// Create the server listening socket for port 1234
try{
ServerSocketConnection scn = (ServerSocketConnection)Connector.open("socket://:1234");
// Wait for a connection.
SocketConnection sc = (SocketConnection) scn.acceptAndOpen();

// Set application specific hints on the socket.
sc.setSocketOption(SocketConnection.DELAY, 0);
sc.setSocketOption(SocketConnection.LINGER, 0);
sc.setSocketOption(SocketConnection.KEEPALIVE, 0);
sc.setSocketOption(SocketConnection.RCVBUF, 128);
sc.setSocketOption(SocketConnection.SNDBUF, 128)

// Get the input stream of the connection.
DataInputStream is = sc.openDataInputStream();

// Get the output stream of the connection.
DataOutputStream os = sc.openDataOutputStream();
} catch (Exception e) {
System.out.println(e.toString());
}
}
}

Last edited by Ojasviharsola : 04-24-2012 at 06:02 AM.
Offline   Reply With Quote