I make a java socket server and c socket client, here are the code
Java Socket Server:
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 socket client:
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));
}
}
}
The problem is .. when i send from the server, it is blocking on flush(), the c client cannot receive until there is another Send_Request called.
where is the problem??