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

Asynchronous UDP Server not working..help pls????

Hi all,

i tried creating a UDP Asynchronous Server.....but am getting errors and am
not able to figure out why!!!.........

here is the code...........

*****************************code starts ********************
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);

IPHostEntry localHostEntry;
localHostEntry = Dns.GetHostByName(Dns.GetHostName());
IPEndPoint ipLocal = new IPEndPoint(localHostEntry.AddressList[0], port);

// Bind to local IP Address...
m_mainSocket.Bind( ipLocal );
// Start listening...
m_mainSocket.Listen(4);
// Create the call back for any client connections...
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
*****************************code ends here********************

The error message is...

ATTEMPTED OPERATION IS NOT SUPPORTED FOR THE TYPE OF OBJECT REFERENCED

what is this error regarding?..

i would be happy if someone could help me around...

thanks in advance...

with regards,
C.C.Chakkaradeep
Nov 17 '05 #1
5 5607
Chakkaradeep wrote:
Hi all,

i tried creating a UDP Asynchronous Server.....but am getting errors
and am not able to figure out why!!!.........

here is the code...........

*****************************code starts ********************
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);

IPHostEntry localHostEntry;
localHostEntry = Dns.GetHostByName(Dns.GetHostName());
IPEndPoint ipLocal = new IPEndPoint(localHostEntry.AddressList[0],
port);

// Bind to local IP Address...
m_mainSocket.Bind( ipLocal );
// Start listening...
m_mainSocket.Listen(4);
// Create the call back for any client connections...
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
*****************************code ends here********************

The error message is...

ATTEMPTED OPERATION IS NOT SUPPORTED FOR THE TYPE OF OBJECT REFERENCED

what is this error regarding?..

i would be happy if someone could help me around...


Accept() and Listen() are intended for use with TCP server sockets.
You're using the wrong API ;-)

For UDP applications, use ReceiveFrom() or BeginReceiveFrom().

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2
Hi,

thanks for the reply..am a newbie in this stuff....

now i have to tell EndReceiveFrom( ) to receive the data after being
BeginReceive( )...will i get the remote end's ip address so that i can use it
in SendTo( ) function??

with regards,
C.C.Chakkaradeep

"Joerg Jooss" wrote:
Chakkaradeep wrote:
Hi all,

i tried creating a UDP Asynchronous Server.....but am getting errors
and am not able to figure out why!!!.........

here is the code...........

*****************************code starts ********************
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);

IPHostEntry localHostEntry;
localHostEntry = Dns.GetHostByName(Dns.GetHostName());
IPEndPoint ipLocal = new IPEndPoint(localHostEntry.AddressList[0],
port);

// Bind to local IP Address...
m_mainSocket.Bind( ipLocal );
// Start listening...
m_mainSocket.Listen(4);
// Create the call back for any client connections...
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
*****************************code ends here********************

The error message is...

ATTEMPTED OPERATION IS NOT SUPPORTED FOR THE TYPE OF OBJECT REFERENCED

what is this error regarding?..

i would be happy if someone could help me around...


Accept() and Listen() are intended for use with TCP server sockets.
You're using the wrong API ;-)

For UDP applications, use ReceiveFrom() or BeginReceiveFrom().

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 17 '05 #3
Hi,

thanks for the reply..am a newbie in this stuff....

now i have to tell EndReceiveFrom( ) to receive the data after being
BeginReceive( )...will i get the remote end's ip address so that i can use it
in SendTo( ) function??

with regards,
C.C.Chakkaradeep

"Joerg Jooss" wrote:
Chakkaradeep wrote:
Hi all,

i tried creating a UDP Asynchronous Server.....but am getting errors
and am not able to figure out why!!!.........

here is the code...........

*****************************code starts ********************
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);

IPHostEntry localHostEntry;
localHostEntry = Dns.GetHostByName(Dns.GetHostName());
IPEndPoint ipLocal = new IPEndPoint(localHostEntry.AddressList[0],
port);

// Bind to local IP Address...
m_mainSocket.Bind( ipLocal );
// Start listening...
m_mainSocket.Listen(4);
// Create the call back for any client connections...
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
*****************************code ends here********************

The error message is...

ATTEMPTED OPERATION IS NOT SUPPORTED FOR THE TYPE OF OBJECT REFERENCED

what is this error regarding?..

i would be happy if someone could help me around...


Accept() and Listen() are intended for use with TCP server sockets.
You're using the wrong API ;-)

For UDP applications, use ReceiveFrom() or BeginReceiveFrom().

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 17 '05 #4
Chakkaradeep wrote:
Hi,

thanks for the reply..am a newbie in this stuff....

now i have to tell EndReceiveFrom( ) to receive the data after being
BeginReceive( )...will i get the remote end's ip address so that i
can use it in SendTo( ) function??


Sure:

public IAsyncResult BeginReceiveFrom(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
ref EndPoint remoteEP,
AsyncCallback callback,
object state
);

Note the EndPoint ref parameter. This will hold a reference to the
remote EndPoint that sends datagrams to your server socket.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #5
Chakkaradeep wrote:
Hi,

thanks for the reply..am a newbie in this stuff....

now i have to tell EndReceiveFrom( ) to receive the data after being
BeginReceive( )...will i get the remote end's ip address so that i
can use it in SendTo( ) function??


Sure:

public IAsyncResult BeginReceiveFrom(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
ref EndPoint remoteEP,
AsyncCallback callback,
object state
);

Note the EndPoint ref parameter. This will hold a reference to the
remote EndPoint that sends datagrams to your server socket.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #6

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

Similar topics

5
by: MikeT | last post by:
I need to start a lengthy file copy process going on our intranet server from a .asp page. Since the .asp cannot wait for this to complete - it might take anything up to half an hour - I've been...
0
by: Pierre Quentel | last post by:
Sorry if the question seems naive, but is there a risk of concurrent accesses to a database if it is accessed only by scripts called by requests to an asynchronous server ? I have the same...
1
by: Chakkaradeep | last post by:
Hi all, i tried creating a UDP Asynchronous Server.....but am getting errors and am not able to figure out why!!!......... here is the code........... *****************************code...
0
by: Simple Simon | last post by:
Hi, excuse the long post and plz read on :) My web application needs to upload a .csv & .zip file, as well as, import the .csv into a (Sql2000) table and unzip the .zip file to a directory on...
9
by: Trint Smith | last post by:
I have tried everything...aspreg -i and modifying machine.config and running the fileupdate...deleting and reinstalling framework 1.1... It only happens when I do a 'Copy Project' to the...
1
by: Mosh | last post by:
I was able to debug an asp.net application with no problems even after installing xp sp2. In the last few days I am getting "Error while trying to run project: Unable to start debugging on the web...
0
by: Andy Lines | last post by:
Hi, I'm using this article by Matt Powell to create an asynchronous server side web method....
1
by: alem | last post by:
Hi Dear all I am new for SQL Server I know VB Programming and Access also but I don't know about SQL Server pls help me or guide me the web site. Thank U in advance.
0
by: cmrhema | last post by:
Hi, We have an asynchronous server socket program, which works fine BUT, when due to some circumstances, I receive null data or blank data, the server goes to infinite loop Here is the code ...
2
by: SvenV | last post by:
I based my program on the asynchronous client/server example on msdn. There weren't too many modifications to the original code. I just created some extra code to response to different messages. F.e....
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.