WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Winsock
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Receive a Line with a CTRL-C in It

Keywords:	sRecvBinary CTRL-C

Question:

I have written a WinBatch PRG that opens a TCP socket to a UNIX box. I then use the a=SSendString (socket, string) function to send it some data. It then sends me data back however instead of the host ending the line with a CR/LF it ends it with a CTRL-C (which is Num2char(3)). I was trying to use the sRecvLine (socket, maxsize) function however it will only terminate if it sees a CR/LF. Is there any way that I can pick up that ASCII data that it is sending me back over that TCP socket connection while it uses a ctrl-c as an end of string. Any ideas?

Answer:

Use sRecvBinary.

It's a bit more of a mess, but I think you are qualified to attack it. Mostly get the example figured out, then you ought to be home free.

Question (continued):

Well, I tried using the sRecvBinary.

I allocated memory for the binary buffer, I used IntControl(42,binbuf,0,0,0) to get a binary address pointer for the buffer, and then I wait for input with stuff=sRecvBinary(socket, binaddr, 1).

I assume this sRecvBinary will "wait" until 1 character enters into the Buffer at which point the function will close and proceed onto the next line.

My script is just sitting at this point and not passing on or even timing out. I have to do a Ctrl-Break to stop the program. I even tried setting the EOD with the BinaryEodSet function to 1 with no avail.

I know that the unix host is sending me data - I can see that with my LAN sniffer and with the unix logs. I know I can send to the unix box with the sSendString (socket, string) function because when I use this function I see it reach the unix box.

I know I cannot use the sRecvLine (socket, maxsize) function because that function is waiting to see a CRLF at the end of the message and my unix box does not send one, it sends a ctrl-c instead.

Hmmmmm.... Is there someway to implement a time-out part to the sRecvBinary (socket, blob, size) that after a certain amount of time it will timeout and just keep the data it was sent and close the socket? Or even if there is a way to implement a way to change what sRecvLine is waiting for to see as the end of the message. Hmmmmm.... Any ideas?

Answer:

Well, it sounds like you have it about right. In any case, if there is no data it should time out in 10 seconds (see wxParmSet). It should not hang in the presence of data in any case.
Article ID:   W12609
Filename:   How to Receive a Line with a Ctrl-C in it.txt
File Created: 2017:07:28:12:58:52
Last Updated: 1999:04:15:15:48:24