473,400 Members | 2,163 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,400 software developers and data experts.

Excessive delay in establishing socket connection

Problem:
We are experiencing an excessive (i.e. 16 - 20 seconds) delay when
attempting to establish socket connection over the network, using the
TcpLister.AcceptSocket() and TcpClient.Connect(ipAddress, Port) calls. It
seems that the delay is between client.Connect() and listener.Accept().

We never have a delay when we use a telnet client to connect to the server.
And we do not have a delay on all networks, just on some. The code we are
using to establish the connection follows.

Thanks in advance!
Server Side...

private void AcceptSocketsThread ()
{
IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, m_Port);
listener = new TcpListener(endpoint);

listener.Start();

//infinite loop... if we have a connection request pending, accept it and
save the socket to our local collection.
while(true)
{
if(listener.Pending()==true)
{
connection =listener.AcceptSocket(); // block for a valid client conection
SocketConnectionList.Add(connection); //save the socket
}
else Thread.Sleep(200);
}
}

Client Side...

public bool SetupClientSocket(string ip,string port)
{
TcpClient client = new TcpClient();

IpAddress=ip;
Port=Int32.Parse(port);

try
{
//try connecting to the socket server...
//this is where we're experiencing the delay...
client.Connect(IpAddress,Port);

return(true);
}
catch (Exception error)
{
return(false);
}
}
Nov 16 '05 #1
0 1400

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

Similar topics

8
by: gs | last post by:
Hi! This is my first time posting to a newsgroup so please be gentle to me :) Introduction to my problem: I'm studying at the university and a lot of friends and I use MSN to communicate....
7
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have...
0
by: Paul | last post by:
I'm trying to use a socket connection from within an asp.net application. It works, but somehow opening the socket seems to be extremely slow. It finally connects and you can transfer information,...
2
by: Cornald Kruyt | last post by:
Hi, I've an database import script written in PHP which used ADO via COM. It makes thousands of queries to a MS-SQL server. The problem is that the process runs out of sockets. The MSSQL...
1
by: CKane | last post by:
i am trying to build a "missed message" queue on a C# TCP server. many of the devices connecting are mobile and may drop out in bad signal areas. i want to store any messages missed for when they...
0
by: Mangabasi | last post by:
Howdy, I would like to use the Synthesis Toolkit for a demo. I downloaded the STK from http://ccrma.stanford.edu/software/stk/index.html. It seems very powerful and user friendly. There are...
2
by: prasath03 | last post by:
Hi, I am using Microsoft SQL Server 2000 Driver for JDBC to connect to SQL Sever 2000. It is just a test application whether its connect or not. But I got the following errors: Error is:...
3
by: Ryan Liu | last post by:
Will TcpClient.GetStream().Read()/ReadByte() block until at least one byte of data can be read? In a Client/Server application, what does it mean at the end of stream/no more data available? ...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
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: 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
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
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...
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...

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.