473,465 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Server socket problem.. client sees connection close before all data received


Hiya,

Been trying to figure this one out. I've written a very simple server
in VB.NET that listens for client connections, then spits out a bunch
of text and then closes the connection. Much like an HTTP server
might do when you request a web page.

The server socket listens for connections using BeginAccept(); and
here's the simple handler function that gets called when a client
connects.

The Problem: I use TELNET from another machine to connect to the
server. I should see the numbers "1 2 3 4 ..." all the way up to
9000. But I usually get to only 5200 or sometimes into the 7000's
before telnet says "Connection to host lost."

I added a LingerOption, for 30 seconds, but that seems to have no
effect. I also tried enabling the "NoDelay" option and that seemed to
make no difference either.

Does anyone know what's going on and how to fix it?

Thanks,
// CHRIS


///////////////////////////////////////////////////////////////////

Public Sub SRV_SOCK_ACCEPT(ByVal ar As System.IAsyncResult)

'Get Server Socket
Dim theServerSocket As Socket = CType(ar.AsyncState, Socket)
'Accept Connection
Dim theClientSock As Socket = theServerSocket.EndAccept(ar)
'Set Linger Option
Dim lingerOptionValue As New LingerOption(True, 30)
theClientSock.SetSocketOption(SocketOptionLevel.So cket, _
SocketOptionName.Linger, lingerOptionValue)
Dim n As Integer 'Counter
Dim theBytes() As Byte 'Byte array for encoding text

For n = 1 To 9000
theBytes = Encoding.ASCII.GetBytes(String.Format("{0} ", n))
theClientSock.Send(theBytes)
Next

theClientSock.Close()

End Sub
///////////////////////////////////////////////////////////////////
Nov 21 '05 #1
2 2485
On Thu, 11 Nov 2004 20:23:01 -0500, CHRISM <ch***@sorry.no.spam.com>
wrote:

<Running with Scissors>
Does anyone know what's going on and how to fix it?

Seems that TELNET isn't very graceful.. I tried the same test using a
program I wrote and it seems to work fine. The problem? TELNET,
apparently, halts when it senses a connection close. They way it
SHOULD work is that it should continue to receive until there is
nothing left to read. THEN close the connection and halt.

// CHRIS

Nov 21 '05 #2
On Thu, 11 Nov 2004 20:23:01 -0500, CHRISM <ch***@sorry.no.spam.com>
wrote:

<Running with Scissors>
Does anyone know what's going on and how to fix it?

Seems that TELNET isn't very graceful.. I tried the same test using a
program I wrote and it seems to work fine. The problem? TELNET,
apparently, halts when it senses a connection close. They way it
SHOULD work is that it should continue to receive until there is
nothing left to read. THEN close the connection and halt.

// CHRIS

Nov 21 '05 #3

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

Similar topics

2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
7
by: Colin | last post by:
I'm writing a little console socket server but I'm having some difficulty. Can I ask your advice - where is the best place to get some help on that topic? It would be nice if some people who knew...
0
by: CHRISM | last post by:
Hiya, Been trying to figure this one out. I've written a very simple server in VB.NET that listens for client connections, then spits out a bunch of text and then closes the connection. Much...
4
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
5
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a...
14
by: ahlongxp | last post by:
Hi, everyone, I'm implementing a simple client/server protocol. Now I've got a situation: client will send server command,header paires and optionally body. server checks headers and decides...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.