Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

socket programming

Status
Not open for further replies.

mlowe9

Programmer
Apr 3, 2002
221
US
I am attempting to create a server application (VB) that takes a data stream from a socket, and puts it into a database. I get this data stream in "chunks", and after each chunk, I need to send data back to the client saying that I got the last chunk, ready for another (acknowledgment, of sorts).

I've got it all working, except sending the acknowledgement data back to the client. It needs to be on the same socket, and I don't get an error on the VB server application, but I also don't see the data on the client application (which is not VB).

Am I not doing something I should be? My code (in essence) is:

Private Sub sock_DataArrival(ByVal bytesTotal As Long)
Dim temp_strData As String
Dim len_tempStrData As Long

sock.GetData temp_strData

strData = strData & temp_strData
len_tempStrData = Len(temp_strData)

parseDataStream (strData) 'function that puts data into DB
strData = ""

'Acknowledge the message
If sock.State = sckConnected Then
sock.SendData (Chr(11) & "ACK" & Chr(28) & Chr(13))
Else
MsgBox "ERROR: Ack not returned."
End If

End Sub
 
This looks correct. It looks like your problem is on the Client side where it will be recieving the data. It is not because you are disconnected because you are trapping that error with "If sock.State = sckConnected " BUT you are not trapping for other errors. Use a "on error goto" line and step through the code to see what error is being passed if any. The winsoc controll will pass you an error if the other side doesnt accept the data or it cant send it. From what I can tell here the data is getting sent but the other side is not getting it or doing anything with it when it gets it. Also I cant tell if you are using tcp or UDP. In your case I hope you are not using UDP.


Hope this helps,
DJTN
 
Sorry for the delay in getting back on here. I've been working on this (still not working) - it looks like it's trying to send the data back on a Remote Port number that is different than what I have set up as the local port number.

Now, being that I have this set up as a server application, the only port that I assigned was the local, why is the remote port different? Is it normal? Should the remote application still accept the data on the remote port that's been assigned?

Thanks
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top