Page 1 of 1

write to socket misbehavior

Posted: Tue Apr 26, 2011 1:10 pm
by xdriver
I'm trying to send some data through tcp socket.
My code looks like below.
Problem is that sometimes( not everytime at least first execution was ok ) first data was not sent to the server.
But second data was successfully received by the server.
This means definitely first write command does not send anything.
How can this happen ?
Am I missing something about socket in Livecode ?

Code: Select all

-- set fetch size
  put binaryEncode( "i", query_id              ) into  pkt_head
  put binaryEncode( "i", PKT_ID_SET_FETCH_SIZE ) after pkt_head
  put binaryEncode( "i", FETCH_SIZE            ) after pkt_head
  
  write pkt_head to socket opened_socket  -- sometimes this data was not sent to the server
  
  put "query_id = " & query_id && "fetch=" & FETCH_SIZE & return into fld "msg"
  
  -- send query text
  put binaryEncode( "i", query_id                        ) into  pkt_head
  put binaryEncode( "i", PKT_ID_COMMAND_TEXT                 ) after pkt_head
  put binaryEncode( "i", the number of chars in command_text ) after pkt_head
  
  write pkt_head to socket opened_socket

Re: write to socket misbehavior

Posted: Tue Apr 26, 2011 2:03 pm
by bangkok
It's very difficult to help you... if you don't tell us how, on the server side, your handler reads the incoming data :)