我做了一个java socket服务器和c socket客户端,这里是代码
Java 套接字服务器:
int Send_Request(String s) {
try {
os = socket.getOutputStream();
os.write(s.getBytes());
os.flush();
Log.d(tag,"Data = " + s);
return 0;
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e(tag,"Send Request Error");
return -1;
}
C套接字客户端:
void* recv_request()
{
int i,in;
char buf[1024];
while(1)
{
if ( ( in = read(sockfd, buf, strlen(buf)) ) != -1 )
{
LOGD("Received = %s ...",buf);
sendServerCutText(buf);
memset(buf,0,strlen(buf));
}
}
}
问题是..当我从服务器发送时,它阻塞了flush(),c客户端无法接收,直到调用另一个Send_Request。
哪里有问题??