|
|
Luis Alonso Ramos wrote:
The problem is that if a change the server and client to use UDP (and datagrams) an exception is thrown in the server at the Listen call.
UPD datagrams support up to 64 KB messages without fragmentation.
If you want to send a bigger portion simply turn on it
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.DontFragment, false);
Another case in which an exception could be thrown is that the default buffer is too small to receive such a big datagram. For example, in UdpClient it's set to 8KB.
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.SendLowWater, 1024 * 128 );
socket.SetSocketOption( SocketOptionLevel.Udp, SocketOptionName.SendBuffer, 1024 * 128 );
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
I tried adding those lines after the creation of the socket, and they throw exceptions (of invalid argument type.)
Anyway, I don't try to send more than 64 KB at a time, it's just a simple 19 byte message.
Any idea why the server will not start listening??
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Could you give the exception's description and its type. It could help.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Yes, this is the exception:
System.Net.Sockets.SocketException: The attempted operation is not supported for
the type of object referenced
at System.Net.Sockets.Socket.Listen(Int32 backlog)
at AsynchronousSocketListener.StartListening() in d:\projects\asyncsock\server\server.cs:line 49 The socket is created like this:
Socket listener = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp); Thanks,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
From what I remember, UDP is a connectionless protocol. Unlike TCP, UDP has no notion of an explicit 'connection' being made to a server socket, which is most likely why this exception is being thrown.
TCP is designed to guaruntee data delivery or to notify the sender and receiver of a delivery failure. In order to do this it keeps alot of state behind the scenes, thus necessitating the 'connection' metaphor.
UDP, however, is much more like IP in that it is a "best effort" delivery protocol. If you send data over UDP, it will most likely get their in good shape. However, it's up to the person reading from the UDP stream to figure out whether or not the data they got has been corrupted.
Long story short - there is no such thing as a 'Connection' or a 'Listen socket' in UDP. If you want to send a data packet via UDP, you specify the data you want to send along with the IP address and port # you want to send it to. You do this for every send() call. Same type of thing with receive() on UDP. You don't connect to a server socket like you would with TCP, you just recv() on a specific port # and wait for someone to send a UDP packet to that port.
My only experience with writing UDP code is in straight C on Unix, so I'm not sure how this would be implemented in the .NET FCL...
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Russell Morris wrote:
You don't connect to a server socket like you would with TCP, you just recv() on a specific port # and wait for someone to send a UDP packet to that port.
So, that is why there is no UdpListener class?? For an UDP server I just start an UdpClient class and call receive on certain port, and it will block until some one calls send on that port?
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
My application needs to support multiple displays. How do I programmaticly move a window/form to a certain displays (monitor)?
If I need to do this with win32 api, what would be the function?
|
|
|
|
|
As long as child forms can move outside the main window, it should have multiple monitor support.
I did note somewhere (cant remember where though) than the position you use is as if the no.1 monitor is the centre monitor in an imaginart monitor grid.
So in my case, 2nd monitor being on the left, the bottom left corner would be (-1024, 768) top right (0,0). Not so sure though
Hope you understand
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
You should be able to get all the info you need about screen points from the System.Windows.Forms.Screen class
|
|
|
|
|
|
AK wrote:
If I need to do this with win32 api, what would be the function?
I presume you meant to ask this in the C++ forum ? If you're asking about C#, you don't need the API at all. Check out James' and my Code Project screensaver, it supports multimonitor in C#.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
What I basicly needed was to get the a form to show up on all the displays center on the screen. This is what I did:
1. Create a form for every screen.
2. Set the location of the form to the screen points (w/ offset to make it centered)
3. Assign all the events to the same event handler. (So all the forms are uniform)
4. Show all the forms.
5. When I get input from the form - all forms are closed.
Thanks for helping me out.
|
|
|
|
|
There is a setting in windows control panel that allows you to set how fast this happens, i wondered if anyone knew how to discover it, so i am not hard coding it.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Hi all,
I have implemented a destructor, and although the destructor gets called and I can step thru the functions, there is this one function that does not "respond". It gets called and returns, but does not do (it does nothing) what its meant to do. I can however assign the same function to a button and it works without any problems.
~CD()
{
this.Stop();
_Free();
}
Any suggestions?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Maybe the resources which Stop function uses are freed before the function is called.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Nope, not it, I have tried calling the unmanaged dll directly with the same effect
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
If you post Stop function's code it'll be simplier to come up with a solution.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
But first do what Nnamdi Onyeyiri advises.
I agree with him.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
|
I meant I'm a
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
|
I believe you may be referring to this man.
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
|
Be careful - the C# destructor is simply a shorthand way of calling the Finalize method that forces it to be written in a try/catch loop. It is NOT guarenteed to run when your object goes out of scope, hence the 'Dispose' paradigm, which is little more than deterministic destruction through a method that you need to remember to call.
I think ( and Jeff Richter agrees ) that calling it a destructor and making it look like a C++ destructor is gay, because it isn't one, and it's confusing that it looks like one.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|