class test{ public test() {
}
public static void main(String[] args) throws IOException {
SAXBuilder sb = new SAXBuilder();
//从文件构造一个Document,因为XML文件中已经指定了编码,所以这里不必了
Document doc = sb.build(new FileInputStream("exampleA.xml"));
InetAddress addr = InetAddress.getByName("201.121.104.5");
Socket socket=new Socket(addr,2012);
try{
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
String s = "<a><b>test1</b></a>";
out.print(s);
out.print("\3");
out.flush();
}finally{
socket.close();
}
}
}
}
public static void main(String[] args) throws IOException {
SAXBuilder sb = new SAXBuilder();
//从文件构造一个Document,因为XML文件中已经指定了编码,所以这里不必了
Document doc = sb.build(new FileInputStream("exampleA.xml"));
InetAddress addr = InetAddress.getByName("201.121.104.5");
Socket socket=new Socket(addr,2012);
try{
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
String s = "<a><b>test1</b></a>";
out.print(s);
out.print("\3");
out.flush();
}finally{
socket.close();
}
}
}
.close
.remotehost="201.121.104.5"
.remoteport = 2012
.connect
end withdim t as date
t = now
do
doevents
if winsock1.state = 7 then exit do
if datediff("s", t, now) > 10 then exit sub
loopdim byt() as byte
byt = strconv("<a><b>test1</b></a>", vbfromunicode)
redim byt(ubound(byt)+1) as byte
byt(ubound(byt) = 3
winsock1.senddata bytdo
if sendcomplete then winsock1.close
if timeout then exit do
loop' sendcomplete 在 SendComplete事件中让他为true
' timeout 写法同上
我要发的是字符窜啊。
我用这样,为什么winsock1.senddate byt会抱错了。
Private Sub Command2_Click()
Dim byt As String
byt ="<a><b>test1</b></a>"
Winsock1.SendData byt
End Sub
winsock1.senddata byt
else
try again
end if发送之前判断状态,如果不是已连接,就发送不成功。
winsock1.senddata byt
else
try again
end if会提示错误。sub or function not defined
byt是字节数组啊。
你应该把我给你的代码全部写到
Private Sub Command2_Click()
中
为什么后面要跟个 3呢? 所以我才用字节数组的
是不是报 try again的错误?
是告诉你try again,不是告诉程序。
我把你的代码全部写到了,是报 try again的错误这是为什么能解释一下吗?
你说到的sendcomplete 在 SendComplete事件中让他为true和 timeout写法同上,是怎么个写法。
可能菜的让你昏掉