473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Getting truncated data from sockets

Hi,

I am listening to a port for data but I am not able to recieve whole
data, I only get truncated data. Client sends me data that exceeds 40K
and the data I recieve in my callback function is always 8K to 9K. I
dont get the rest of the data. I think the data size is too big to come
in one go and hence it comes in 2-3 sub-packages but my call back
function only gets called once hence I am getting truncated data. I am
sending the code...Is there anyway I can recieve complete data sent by
client
Public Function ConnecttSocket(byVal iPort as integer)

Dim _sHostName As String

Dim _iLocalPort As Integer = iPort

Dim LocalIp() As IPAddress

Dim _oIPHostEntry As IPHostEntry

Dim IPLocalEndPoint As IPEndPoint

oListenerSocket = New Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp)

_sHostName = Dns.GetHostName()

_oIPHostEntry = Dns.GetHostByName(_sHostName)

LocalIp = _oIPHostEntry.AddressList()

IPLocalEndPoint = New IPEndPoint(LocalIp(0), _iLocalPort)

oListenerSocket.Bind(IPLocalEndPoint)

oListenerSocket.Listen(4)

oListenerSocket.BeginAccept(New AsyncCallback(AddressOf
onClientConnect), Nothing)

End Function

Private Sub onClientConnect(ByVal asyn As IAsyncResult)

Try

workerSocket = oListenerSocket.EndAccept(asyn)

SocketWaitForData(workerSocket)

oListenerSocket.BeginAccept(New AsyncCallback(AddressOf
onClientConnect), Nothing)

Catch ex As Exception

MessageBox.Show("onClientConnect " + ex.Message.ToString())

End Try

End Sub

Private Sub SocketWaitForData(ByVal soc As Socket)

Try

If SocketpfnCallBack Is Nothing Then

SocketpfnCallBack = New AsyncCallback(AddressOf SocketOnDataRcvd)

End If

result = soc.BeginReceive(SocketDataBuffer, 0, SocketDataBuffer.Length,
SocketFlags.None, SocketpfnCallBack, Nothing)

Catch ex As Exception

MessageBox.Show("SocketWaitForData " + ex.Message.ToString())

End Try

End Sub

Private Sub SocketOnDataRcvd(ByVal asyn As IAsyncResult)

Dim iRx As Integer = 0

Dim sSocketMessage As System.String

Try

iRx = workerSocket.EndReceive(asyn)
'iRx always shows 9K or 8K, I think this is the maximum capacity of
sockets to 'transfer data in one go

Dim chars(iRx + 1) As Char

Dim d As System.Text.Decoder = System.Text.Encoding.UTF8.GetDecoder()

Dim charlen As Integer = d.GetChars(SocketDataBuffer, 0, iRx, chars, 0)

sSocketMessage = New System.String(chars)

end sub

Nov 28 '05 #1
2 2005
<bi******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,

I am listening to a port for data but I am not able to recieve whole
data, I only get truncated data. Client sends me data that exceeds 40K


I can't help with the code (no .Net experience to share yet <g>) but I can
tell you that you can never base your app on the hopes of getting full
packets (serial or TCP/IP) so you always have to buffer the data.

fwiw, if full packets is all you ever want to deal with.... and are sure
that you can control blocking, etc, in a meaningful way, you can use
SocketWrench... their new version supports fixed sized transfers where both
sides wait until the entire packet is transferred. It's a bit tricky because
of the blocking and handshaking but it's possible. This functionality may be
in their freeware version as well so.....

http://www.catalyst.com/

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Nov 28 '05 #2
<bi******@gmail.com> schrieb im Newsbeitrag
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,

I am listening to a port for data but I am not able to recieve whole
data, I only get truncated data. Client sends me data that exceeds 40K
and the data I recieve in my callback function is always 8K to 9K. I
dont get the rest of the data. I think the data size is too big to come
in one go and hence it comes in 2-3 sub-packages but my call back
function only gets called once hence I am getting truncated data. I am
sending the code...Is there anyway I can recieve complete data sent by
client


I have never done it on my own, but in the documentation on the EndReceive
method, there is an example where BeginReceive is called again.
Armin

Nov 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Howard Kaikow | last post by:
How do I find where I am screwing up? Using the following in Eudora, and equivalent links elsewhere, the URLs with the # get truncated just before the #. <a...
2
by: | last post by:
Hi everyone, I'm using VS.NET, Framework 1.1, Windows 2000 Server, IIS 5, all the latest patches are installed. Im having this wierd random problem, that I cannot reproduce but it happens...
5
by: z. f. | last post by:
hi, i have a vb.net web application and i make a request using internet explorer to an aspx page. the aspx page size if over 170KB, and the page in internet explorer looks truncated and in the...
0
by: David A. Schramm | last post by:
I am using OLE DB in .NET 2 to insert a row into an Access database. The source is a RTF control and the column is a Memo field. The data is being truncated along the way. The control's rtf...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
5
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable...
7
Coldfire
by: Coldfire | last post by:
i am having error ....details are ASP.Net application...in which I have a textbox <asp:TextBox ID="Other" TextMode=SingleLine CssClass="serviceBox" Width="250" Height="45" Runat="server"...
1
by: Veeru71 | last post by:
When I am SELECT'ing a CLOB column from command prompt, the output is getting truncated after a certail limit (8 K ??) How do I get the full data out of a CLOB column? Are there any string...
5
by: Kenny D | last post by:
I am having trouble sending streams of data from one socket to another using the following code. When the transmitter is running on the same machine as the receiver, the data transmits...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.