473,385 Members | 1,641 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.

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 2483
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.