473,327 Members | 1,920 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,327 software developers and data experts.

Asyncronous UDP slows down

2
Hi,

I'm creating a high preformance server which uses udp to query at least 100 servers continiously.

The application is made in VS2005 using I/O Completion ports.

In the beginning, everything goes well, but after a few dozen query's. It seems to be slowed down terrible.

Explaining better: I got a timeout thread because UDP is connectionless and i dont want to keep destroying and recreating the sockets. Everytime a socket is noticed as timeout, it will set another internal unique value ( to check whether an incoming packet really belongs to that active server ) and does a new query.

The first minute there is no timeout. After that 9 / 10 query's fail.

The code to send and recieve:

Expand|Select|Wrap|Line Numbers
  1.             template <typename T>
  2.             ESocketStatus CASyncUdpSocket<T>::Send(const char* p_ptData, size_t p_dwLength){
  3.                 m_objWsaBuffer.len = p_dwLength;
  4.                 m_objWsaBuffer.buf = const_cast<char*>(p_ptData); //We can assume that the data wont be touched
  5.  
  6.                 DWORD dwResult = WSASendTo(get_Socket(),
  7.                     &m_objWsaBuffer,
  8.                     1,
  9.                     &m_dwLastSend,
  10.                     NULL,
  11.                     reinterpret_cast<const sockaddr*>(&m_objConnectedAddress),
  12.                     sizeof(m_objConnectedAddress),
  13.                     get_Overlapped(),
  14.                     NULL );
  15.  
  16.                 if (dwResult == SOCKET_ERROR){
  17.                     if (WSAGetLastError() != WSA_IO_PENDING){
  18.                         __report << "Error sending: " << WSAGetLastError() << "\n";
  19.                         return e_Failed;
  20.                     }
  21.                 }    
  22.  
  23.                 return e_Succeeded;
  24.             }
  25.  
  26.             template <typename T>
  27.             ESocketStatus CASyncUdpSocket<T>::Recieve(char* p_pStrBuffer, size_t p_dwLength){
  28.                 m_objWsaBuffer.len = p_dwLength;
  29.                 m_objWsaBuffer.buf = p_pStrBuffer;
  30.                 m_iFromLength = sizeof(sockaddr_in);
  31.                 m_dwLastRecieved = 0;
  32.                 m_dwFlags = 0;
  33.                 DWORD dwResult = WSARecvFrom(get_Socket(),
  34.                     &m_objWsaBuffer,
  35.                     1,
  36.                     &m_dwLastRecieved,
  37.                     &m_dwFlags,
  38.                     reinterpret_cast<sockaddr*>(&m_objConnectedAddress),
  39.                     &m_iFromLength,
  40.                     get_Overlapped(),
  41.                     NULL );
  42.  
  43.                 if (dwResult == SOCKET_ERROR){
  44.                     if (WSAGetLastError() != WSA_IO_PENDING){
  45.                         __report  << "Recieve failed: " << WSAGetLastError();
  46.                         return e_Failed;
  47.                     }
  48.                 }
  49.  
  50.                 return e_Succeeded;
  51.             }
I really dont know what happends, however i suspect that for some or other reason a NIC devices cant take it, however my download didnt changed a bit looking at the speed.

Interresting: It seems that every send goes well out of my socket, however after that minute, most recieves fail. only a few succeeds ( noticed with ethereal packet tracer )
May 20 '07 #1
0 968

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Gerald Khin | last post by:
I encountered a performance problem with UPDATE statement and foreign key constraints. There are two tables involved: A parent table A and a child table B: create table A( ID CHAR(15) NOT...
6
by: Larry R Harrison Jr | last post by:
I have a database I'm designing in Access 97. I have a custom field in a query which looks in {Table of Documents} and shows them all. It then needs a "latest revision number," stored in another...
1
by: il RicercatoreSbadato | last post by:
title: asyncronous Socket and EndAccept() question: hi to all, I am working with a server that uses the sockets in a asyncronous way. When I want to STOP the server I do the following: -...
9
by: cow3 | last post by:
Is there anyone who can help me with this: I have written a fairly complicated vb application of hydrological model that does a lot of number crunching. The model creates a set of object...
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
1
by: Jose Walker | last post by:
Hi there, I've an ASP.NET 2 web application that I want to publish, but it happened that the application slows down in performance compared with the version managed by VS.NET 2005. When the...
3
by: OJ | last post by:
Hi, I have written a small C# 2.0 DLL which acts as a client to a Socket based server over the internet. I have written both synchronous and asynchronous methods to connect, send, and receive data...
6
by: jacc14 | last post by:
Good morning all. I have been working on a database for the past couple of weeks and it is pretty nippy. I have an ODBC link in there from another software program. Since splitting it and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.