difficulty with wsockreaddata
- Posted by Alan Tu <alantu at STUDENTS.UIUC.EDU> Mar 20, 2000
- 421 views
First, I'd like to express my appreciation to the Winsock team for doing much of the dirty work in coding all these API calls. The following code (which I'm having trouble with) is a modified snippet of Greg Harris's wsclient.exw in the winsock package. In general terms, my program has no trouble connecting to my pop server. It has no trouble sending and receiving data. Its the parsing that I'm having trouble with. At this point in the code, the program has connected to my server. errorRtn = WsockSendData(client,"user alantu\n") errorRtn = WsockSendData(client,"pass x\n") --assuming my password is x errorRtn = WsockSendData(client,"stat\n") -- The purpose of this program (as a first step) -- is to check if there are messages. errorRtn = WsockReadData(client,80) errorRtn = WsockReadData(client,80) errorRtn = WsockReadData(client,17) errorRtn = WsockReadData(client,12) if sequence(errorRtn) then Say(errorRtn,"Winsock Says!") end if --closes connection For one particular set of data, the code works by popping up a dialog saying +ok 2 4746! But of course, I might have 10 messages (one extra digit) or I might have 0 messages. If I fiddle with the bytes to read, sometimes the dialog displays nothing (actually, no dialog comes up at all). I looked at the read data routine and it seems that there's a while loop and when there's no more to read, it exits. So I figured after each input I'd read 80 characters to get a max one line. If there were fewer characters, then the sequence would just have that line. I had a read data after each send data and just tried to display the last read data, but that didn't work either. I can't think of a clean (or even a workable general solution) to this problem. Can someone help me? Thanks. Alan