TCP Socket Question

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 13
Reputation: firebirds98 is an unknown quantity at this point 
Solved Threads: 0
firebirds98 firebirds98 is offline Offline
Newbie Poster

TCP Socket Question

 
0
  #1
Jul 11th, 2008
My problem is that I am not receiving all of the data that I should be. I am only receiving 7 records rather then receiving 12. Is there a time limit that a socket can recieve for? Is there something else that could be my problem that I would not be receiving all of the information that the server is definitly sending me?

My receive code
  1. Dim cpBytesRec As Int64 = sender2.Receive(bytes)
  2. dataFromCp = Encoding.ASCII.GetString(bytes, 0, cpBytesRec)
  3. Console.WriteLine("Data From ChoicePoint = {0}", dataFromCp)



All of the code
  1. Private Function TransmitToCP(ByVal data As Byte()) As String
  2.  
  3. Dim cpPort As Integer = 10102
  4. Dim bytes(1500) As Byte
  5. Dim dataFromCp As String = ""
  6. Dim CPDATA As String = ""
  7. Dim longip As IPAddress
  8. longip = IPAddress.Parse("67.241.41.236")
  9.  
  10.  
  11. Try
  12. Dim cpServerEP As New IPEndPoint(longIP, cpPort)
  13.  
  14. ' Create a TCP/IP socket.
  15. Dim sender2 As New Socket(AddressFamily.InterNetwork, _
  16. SocketType.Stream, ProtocolType.Tcp)
  17.  
  18. Console.WriteLine("Socket waiting to connect to cp")
  19.  
  20. ' Connect the socket to the remote endpoint. Catch any errors.
  21. Try
  22. sender2.Connect(cpServerEP)
  23.  
  24. Console.WriteLine("Socket connected to cp {0}", _
  25. sender2.RemoteEndPoint.ToString())
  26.  
  27.  
  28. ' Send the data through the socket.
  29. Dim bytesSent As Integer = sender2.Send(data)
  30.  
  31.  
  32.  
  33. ' Receive the response from the remote device.
  34. Dim cpBytesRec As Int64 = sender2.Receive(bytes)
  35. dataFromCp = Encoding.ASCII.GetString(bytes, 0, cpBytesRec)
  36. Console.WriteLine("Data From ChoicePoint = {0}", dataFromCp)
  37.  
  38.  
  39. ' Release the socket.
  40. sender2.Shutdown(SocketShutdown.Both)
  41. sender2.Close()
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1
Reputation: bonave is an unknown quantity at this point 
Solved Threads: 0
bonave bonave is offline Offline
Newbie Poster

Re: TCP Socket Question

 
0
  #2
Jul 17th, 2008
If u socket.flush() after sending data , i think it you will get all records .

If you a beginner in vb.net socket programming , just follow the link , that one is intenteded for beginners .

http://vb.net-informations.com/commu...rogramming.htm

bonave
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC