Somewhere around 500 connections when calls (BeginSend calls) are
arround 108,752 and total bytes sent are around 9,496,399 bytes - send
callbacks (EndSend) stop coming in C# asynchronous sockets.
I'm counting how many BeginSend are issued and how many EndSend are
received, and somewhere around 500 connections send callbacks stop
coming even when the count for BeginSend shows that there are pending
sends in the system.
Here is the code:
private void SendData(OState Object so, string sData)
{
byteData = Encoding.ASCII. GetBytes(sData) ;
try
{
so.socket.Begin Send(byteData, 0, byteData.Length , 0, new
AsyncCallback(S endCallback), so);
PendingSends = Interlocked.Inc rement(ref PendingSends);
}
catch(System.Ob jectDisposedExc eption)
{
}
catch (SocketExceptio n e)
{
DestoryStateObj ect(so);
}
catch (Exception e)
{
DestoryStateObj ect(so);
}
}
private void SendCallback(IA syncResult ar)
{
OStateObject so = (OStateObject)a r.AsyncState;
try
{
MaxSendBytes += so.socket.EndSe nd(ar);
PendingSends = Interlocked.Dec rement(ref PendingSends);
}
catch (SocketExceptio n e)
{
PendingSends = Interlocked.Dec rement(ref PendingSends);
DestoryStateObj ect(so);
}
catch (Exception e)
{
PendingSends = Interlocked.Dec rement(ref PendingSends);
DestoryStateObj ect(so);
}
}
Here is code from the timer which executes this code every 2 second.
if (ArrayListConne ctedSockets.Cou nt >= 500)
{
//"TBGSends" is a global variable to keep track of maximum number of
sends
string bgMsg = "TestData :ghghe ghghghghgh whrerhehrehreh
hththththththth ht eherehherehhee ghghe ghghghghgh whrerhehrehreh
hththththththth ht eherehherehhee\ n";
OStateObject so;
for (int i=0; i<ArrayListConn ectedSockets.Co unt || TBGSends <= 150000;
i++)
{
so = (OStateObject)A rrayListConnect edSockets[i];
SendData(so, bgMsg);
TBGSends++;
}
if (TBGSends >= 150000) TimerBG.Stop();
}
I'm restricting maximum number of connection to 1000 after reaching
this limit server shuts down every new connection.
Maximum a user can send 5 times within a second. If there are 1024
users connected to each other than the server would make 1047552 send
calls if all users send something to each other with in few seconds. 1
or 2 seconds delay doesn't matter but the server jams during the
communication.
Why the server is jamming and anyway to solve this problem in C#? 0 1536 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David |
last post by:
Hi,
Ive been trying to work this out for the past 2 days now and im not
getting anywhere fast.
The problem i have is that i am using Asynchronous sockets to create a
Socket Client library. When i try to connect to a server that doesnt
exist it raises a "Connection forcibly rejected by the resmote host"
SocketException.
|
by: Matthew King |
last post by:
Hi all
I've written a asynchronous socket client class, but i've found that in order to consume it I have to use events, and cannot simply for example
SocketClient client = new SocketClient(110, "some.server.com")
client.Connect()
client.SendData("Hello World")
Instead I have to wait for the async method to raise a Connected event, and call client.SendData from there, for complex chains of operations this because a nightmare chain of...
|
by: Michael Lindsey |
last post by:
I need to write a server app to send images to client GUIs that are outside
of the server's domain.
The client will have the file system path to the image but can not access
the file system.
I am trying to decide if I should use remoting vs. writing a server that
uses networkstreams.
I have read that networkstreams\tcp programming should be faster than
remoting and is a better choice for what I am doing but that it is difficult
to code.
|
by: Kruz |
last post by:
Somewhere around 500 connections when calls (BeginSend calls) are
arround 108,752 and total bytes sent are around 9,496,399 bytes - send
callbacks (EndSend) stop coming in C# asynchronous sockets.
I'm counting how many BeginSend are issued and how many EndSend are
received, and somewhere around 500 connections send callbacks stop
coming even when the count for BeginSend shows that there are pending
sends in the system.
Here is the...
|
by: Assaf Shemesh |
last post by:
Hi,
I'm having a problem with asynchronous HttpWebRequest. It's a simple
http client-server. For most of my users it works fine. However, some
of them get the exception:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: The attempted operation is not
supported for the type of object referenced
at System.Net.Sockets.Socket.get_ConnectEx()
| |
by: DaTurk |
last post by:
Hi,
Lets see, for arguements sake lets just say that I have a server,
which site waiting to receive connections, it then has an array of
sockets that are connected to it.
It's receiving all of this asynchronously. Now, this is my problem, I
have a seperate application that connects to the server and can
disconnect any of the sockets connected to it. But, lets just say I
have one client connected, and then I attempt to disconnect them...
|
by: Engineerik |
last post by:
I am trying to create a socket server which will listen for connections from
multiple clients and call subroutines in a Fortran DLL and pass the results
back to the client. The asynchronous socket client and asynchronous socket
server example code provided in the .NET framework developers guide is a
great start but I have not dealt with sockets before and I am struggling with
something.
From what I can tell the sample server code ...
|
by: Nicolas Le Gland |
last post by:
Hello everyone here.
This is my first post in this newsgroup, I hope I won't be to much
off-topic. Feel free to redirect me to any better group.
I am getting strange timing issues when failing to asynchronously connect
sockets on closed or filtered ports, but I'm quite unsure if this is a PHP
issue or my misunderstanding, as it seems that socket streams only wrap
around <sys/socket.h>.
|
by: alan |
last post by:
Hello all, I'd like to ask recommendations about a "good" generic
asynchronous I/O library for C++. By generic I mean, something I can
use even on files, stdin/stdout, and sockets.
I've seen boost::asio, and also ioxxx, but most of the examples I've
seen with them are about sockets. Can they be used for general i/o
(files, terminal)? Can anyone point me to good tutorials about using
them for stuff other than sockets?
My use case...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |