[Mono-bugs] [Bug 661437] New: 2.8.1: Connect/Send logic on UDP sockets is throwing inappropriately
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Dec 26 20:23:45 EST 2010
https://bugzilla.novell.com/show_bug.cgi?id=661437
https://bugzilla.novell.com/show_bug.cgi?id=661437#c0
Summary: 2.8.1: Connect/Send logic on UDP sockets is throwing
inappropriately
Classification: Mono
Product: Mono: Class Libraries
Version: 2.8.x
Platform: Macintosh
OS/Version: Mac OS X 10.6
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: brian at sooloos.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US)
AppleWebKit/534.15 (KHTML, like Gecko) Chrome/10.0.612.3 Safari/534.15
This seems like a regression--code that was working with 2.6.7 is now failing
with 2.8.1. The cases I discovered when investigating further are:
If I use BeginSend() on a Connect()'ed multicast UDP socket, I get the
following exception:
Unhandled Exception: System.Net.Sockets.SocketException: The socket is not
connected
at System.Net.Sockets.Socket.BeginSend (System.Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socket_flags, System.AsyncCallback callback,
System.Object state) [0x00000] in <filename unknown>:0
at Test.TestAsyncSend () [0x00000] in <filename unknown>:0
at Test.Main (System.String[] args) [0x00000] in <filename unknown>:0
If I use BeginSendTo() on a Connect()'ed multicast UDP socket, I get the
following exception:
Unhandled Exception: System.Net.Sockets.SocketException: Socket is already
connected
at System.Net.Sockets.Socket.SendTo_nochecks (System.Byte[] buffer, Int32
offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)
[0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket+Worker.SendTo () [0x00000] in <filename
unknown>:0
if I use SendTo() on a Connect()'ed multicast UDP socket, I get the following
exception:
Unhandled Exception: System.Net.Sockets.SocketException: Socket is already
connected
at System.Net.Sockets.Socket.SendTo_nochecks (System.Byte[] buffer, Int32
offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)
[0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.SendTo (System.Byte[] buffer, Int32 offset,
Int32 size, SocketFlags flags, System.Net.EndPoint remote_end) [0x00000] in
<filename unknown>:0
at Test.TestConnectedSyncSendTo () [0x00000] in <filename unknown>:0
at Test.Main (System.String[] args) [0x00000] in <filename unknown>:0
I made a test program to test six combinations of system calls.
The failure cases are asyncsend, connectedsyncsendto, connectasyncsendto. The
other three test cases work as expected. I would expect all six to work.
$ cat udp.cs
using System;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
class Test
{
enum Mode { SyncSend, SyncSendTo, AsyncSend, AsyncSendTo,
ConnectedSyncSendTo, ConnectedAsyncSendTo }
static byte[] buf = new byte[40];
static void Usage() {
Console.Error.WriteLine("Usage mono udp.exe <mode> where <mode> is one
of:");
Console.Error.WriteLine(" syncsend - use
socket.Send()");
Console.Error.WriteLine(" syncsendto - use
socket.SendTo()");
Console.Error.WriteLine(" connectedsyncsendto - use socket.SendTo()
on a Connect()'ed socket");
Console.Error.WriteLine(" asyncsend - use
socket.BeginSend()");
Console.Error.WriteLine(" asyncsendto - use
socket.BeginSendTo()");
Console.Error.WriteLine(" connectedasyncsendto - use
socket.BeginSendTo() on a Connect()'ed socket");
}
static void TestSyncSend() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
sock.Connect(new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002));
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
while (true) {
Console.WriteLine("Send()");
sock.Send(buf, 0, buf.Length, 0);
Thread.Sleep(1000);
}
}
}
static void TestConnectedSyncSendTo() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
EndPoint ep = new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002);
sock.Connect(ep);
while (true) {
Console.WriteLine("SendTo()");
sock.SendTo(buf, 0, buf.Length, 0, ep);
Thread.Sleep(1000);
}
}
}
static void TestSyncSendTo() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
EndPoint ep = new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002);
while (true) {
Console.WriteLine("SendTo()");
sock.SendTo(buf, 0, buf.Length, 0, ep);
Thread.Sleep(1000);
}
}
}
static void TestAsyncSend() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
sock.Connect(new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002));
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
while (true) {
Console.WriteLine("BeginSend()");
sock.BeginSend(buf, 0, buf.Length, 0, ar => {
Console.WriteLine(" ==> EndSend()");
sock.EndSend(ar);
}, null);
Thread.Sleep(1000);
}
}
}
static void TestConnectedAsyncSendTo() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002);
sock.Connect(ep);
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
while (true) {
Console.WriteLine("BeginSendTo()");
sock.BeginSendTo(buf, 0, buf.Length, 0, ep, ar => {
Console.WriteLine(" ==> EndSendTo()");
sock.EndSendTo(ar);
}, null);
Thread.Sleep(1000);
}
}
}
static void TestAsyncSendTo() {
using (Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)) {
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("239.255.255.249"),
9002);
sock.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.MulticastTimeToLive, 2);
while (true) {
Console.WriteLine("BeginSendTo()");
sock.BeginSendTo(buf, 0, buf.Length, 0, ep, ar => {
Console.WriteLine(" ==> EndSendTo()");
sock.EndSendTo(ar);
}, null);
Thread.Sleep(1000);
}
}
}
public static int Main(string[] args) {
Mode mode;
try {
mode = (Mode)Enum.Parse(typeof(Mode), args[0], true);
} catch { Usage(); return 1; }
switch (mode) {
case Mode.SyncSend: TestSyncSend(); break;
case Mode.SyncSendTo: TestSyncSendTo(); break;
case Mode.ConnectedSyncSendTo: TestConnectedSyncSendTo(); break;
case Mode.AsyncSend: TestAsyncSend(); break;
case Mode.AsyncSendTo: TestAsyncSendTo(); break;
case Mode.ConnectedAsyncSendTo: TestConnectedAsyncSendTo(); break;
}
return 0;
}
}
to run:
$ gmcs udp.cs && mono udp.exe asyncsend
BeginSend()
Unhandled Exception: System.Net.Sockets.SocketException: The socket is not
connected
at System.Net.Sockets.Socket.BeginSend (System.Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socket_flags, System.AsyncCallback callback,
System.Object state) [0x00000] in <filename unknown>:0
at Test.TestAsyncSend () [0x00000] in <filename unknown>:0
at Test.Main (System.String[] args) [0x00000] in <filename unknown>:0
$ gmcs udp.cs && mono udp.exe connectedasyncsendto
[ 130 ]
BeginSendTo()
==> EndSendTo()
Unhandled Exception: System.Net.Sockets.SocketException: Socket is already
connected
at System.Net.Sockets.Socket.SendTo_nochecks (System.Byte[] buffer, Int32
offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)
[0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket+Worker.SendTo () [0x00000] in <filename
unknown>:0
$ gmcs udp.cs && mono udp.exe connectedsyncsendto
[ 255 ]
SendTo()
Unhandled Exception: System.Net.Sockets.SocketException: Socket is already
connected
at System.Net.Sockets.Socket.SendTo_nochecks (System.Byte[] buffer, Int32
offset, Int32 size, SocketFlags flags, System.Net.EndPoint remote_end)
[0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.SendTo (System.Byte[] buffer, Int32 offset,
Int32 size, SocketFlags flags, System.Net.EndPoint remote_end) [0x00000] in
<filename unknown>:0
at Test.TestConnectedSyncSendTo () [0x00000] in <filename unknown>:0
at Test.Main (System.String[] args) [0x00000] in <filename unknown>:0
Reproducible: Always
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list