import java.io.*;
import java.net.*;
public class Client
{
public void SendData()
{
Socket clientSock=null;
String str="Asia";
try
{
clientSock=new Socket("127.0.0.1",10000);
if(clientSock!=null)
{
System.out.println("now,the state is connected!");
}
PrintWriter sockOutput= new PrintWriter(clientSock.getOutputStream());
sockOutput.println(str);
sockOutput.flush();
}
catch(Exception e)
{
e.getStackTrace();
}
}
public static void main(String args[])
{
Client c=new Client();
c.SendData();
}
}
这个是客户端的发送程序
我在服务器端用vb winsock控件接收
接收端可以收到
dim str as String
wska.getData str
Select Case str //设置断点后看到str="Asia",可能是类型不匹配,不能进入case 语句
是不是发送端的问题
Case "China"
Map1.GeoSet = "China"
Case "WorldCountries"
Map1.GeoSet = "World Countries"
Case "Australia"
Map1.GeoSet = "Australia"
Case "Canada"
Map1.GeoSet = "Canada"
Case "Asia"
Map1.GeoSet = "Asia"
End Select