-
socket communication
hi friends, I hava a problem and hope someone can help me... I use VB Socket
server and Java Socket client to communicate with each other.i used winsock
control in vb server.when i'm sending data from vb server to client in java,the
client getting data only after closing the vb server. Is there any settings
needed to be configured before sending or receiving data ?
and my java code is
import java.net.*;
import java.io.*;
public class Testclient
{
public static void main (String args[])
{
if (args.length !=2)
System.out.println(" client host port"); else
{
String inp;
try
{
Socket sock = new Socket(args[0], Integer.valueOf(args[1]).intValue());
//BufferedReader is = new BufferedReader( new InputStreamReader (sock.getInputStream()));
DataInputStream d1;
d1=new DataInputStream(new BufferedInputStream(sock.getInputStream()));
System.out.println("address : " + sock.getInetAddress());
System.out.println("port : " + sock.getPort());
System.out.println("Local address : " + sock.getLocalAddress());
System.out.println("Localport : " + sock.getLocalPort());
DataOutputStream out = new DataOutputStream(sock.getOutputStream());
System.out.println("Send a goodbye");
out.writeBytes("Thank you, and goodbye");
System.out.println("Waiting for input..");
//d1=new DataInputStream(new BufferedInputStream(sock.getInputStream(),2500));
inp = d1.readLine();
System.out.println("From server:" + inp);
//while ( (inp = is.readLine()) != null)
//{
// System.out.println("from client:"+inp);
//}
//DataOutputStream out = new DataOutputStream(sock.getOutputStream());
//System.out.println("Send a goodbye");
//out.writeBytes("Thank you, and goodbye");
d1.close();
sock.close();
//is.close();
}
catch (UnknownHostException e)
{
System.out.println(" Known Host : " + e.getMessage());
}
catch (IOException e)
{
System.out.println("error I/O : " + e.getMessage());
}
finally
{
System.out.println("End of program");
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks