write to socket misbehavior

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
xdriver
Posts: 4
Joined: Thu Mar 31, 2011 11:39 am

write to socket misbehavior

Post by xdriver » Tue Apr 26, 2011 1:10 pm

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: write to socket misbehavior

Post by bangkok » Tue Apr 26, 2011 2:03 pm

It's very difficult to help you... if you don't tell us how, on the server side, your handler reads the incoming data :)

Post Reply