Commit Graph
79 Commits
Author SHA1 Message Date
Kei Nakazawa dc30595ace [System] Added missing ctor to Socket for initializing dual-mode socket
- Ref: https://bugzilla.xamarin.com/show_bug.cgi?id=20048
 - Mono currently doesn't support 2-args Socket ctor added in .NET 4.5
 - Absence of this ctor prevents KestrelHttpServer (web server for
   ASP.NET vNext: https://github.com/aspnet/KestrelHttpServer ) test
   code from working
 - I hesitated to put IPv4 only implementation, but full dual stack
   (IPv4/v6) support would need bunch of works to be done. So, I pinned
   supported protocol of new ctor to IPv4. Also, I filed v4/v6 support
   issue as a MonoTODO entry inside the source code.
2014-10-26 02:57:22 +09:00
Alexander Köplinger 48e112d652 [Cleanup] Removed TARGET_JVM
It was once part of a special Java target profile, but this is no longer used today.
2014-08-08 03:28:34 +02:00
Ivo Smits 0e2f0a23b6 Fixed NullReferenceExcepton in Socket.Connect for non-IP endpoints
Socket.Connect(EndPoint) throws a NullReferenceException when connecting to non-IP (eg Unix) endpoints in Dgram mode.
2014-06-24 00:21:06 +02:00
Jonathan Shore e6b8be8cba minor fix for bug 9520:
- socket configuration attempts to determine if system supports ipv6
- checks app configuration, but configuration throws exception if called from embedded context
- solution is to put a try/catch guard and fall to an alternative test for ipv6
2013-03-16 11:34:59 -04:00
Rodrigo Kumpera f378e23a3f Since NET_2_1 implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:41:51 -05:00
Rodrigo Kumpera 5007c14d62 Kill the MOONLIGHT define in System. 2013-02-11 13:01:11 -05:00
Rodrigo Kumpera a518a41512 Make the thread abort code multi-thread safe. 2012-06-27 19:59:57 -03:00
Rodrigo Kumpera 956dba9d5c With Socket:Dispose from using Thread.Abort to less agressive alternative.
* Socket_2_1.cs: When closing a socket we need to abort any
	pending syscalls to that socket. For most syscalls the kernel
	does it for us. But accept/connect on linux requires extra
	love.

	We previously used Thread.Abort to implement that, but this
	is a pretty radical solution with very complicated ramifications.
	So instead now we use a new icall cancel_blocking_socket_operation
	that makes sure we only abort the syscall and do nothing else.

	This reduces the trouble surface a lot given how tricky
	Thread.Abort is.
2012-06-27 19:59:56 -03:00
Martin Baulig eb0ef90fc4 Fix async sockets: don't set Count=0 when reusing SocketAsyncEventArgs.
This reverts commit e2e44bf6f4 (from May
2011).

Added SocketAsyncTest.cs to test this.
2012-06-19 01:10:12 +02:00
Marek Safar d5d4b9c22b Fix some warnings 2012-06-08 12:48:08 +01:00
Gonzalo Paniagua Javier 70c64f12c3 Fix multiple async accepts
Running multiple BeginAccepts or AcceptAsync at the same time on the
	same socket requires serialization.
	Fixes bug #3805.
2012-03-08 14:32:49 -05:00
Marek Safar 2869713c48 Fix some compiler warnings 2012-02-17 12:37:25 +00:00
QuickJack 215fca80b8 Fixes a warning in System.dll 2011-12-27 19:05:28 +01:00
Martin 6e9b58656b Removes warning CS0219 in line 1647 2011-12-02 14:43:46 +01:00
Konrad M. Kruczynski c8d9d4355b Also zeroing in case of exception. 2011-08-30 19:43:46 +02:00
Konrad M. Kruczynski 9c42017230 Fix for bug #531 as proposed by aldem. 2011-08-30 19:38:03 +02:00
Konrad M. Kruczynski 5cf1cb6a13 Revert "Fix for Xamarin bug #531" - it will be fixed another way.
This reverts commit d1d1dd6198.
2011-08-30 18:57:47 +02:00
Konrad M. Kruczynski d1d1dd6198 Fix for Xamarin bug #531. 2011-08-30 02:05:21 +02:00
XTZGZoReX a552981293 Socket: Fixed a security issue when default-initialized ArraySegment structs are passed in.
This is the same security issue that was recently addressed in MS.NET.
2011-06-20 01:02:00 +02:00
ualtinok e2e44bf6f4 Set Count to 0 as well as BytesTransferred when reusing a SocketAsyncEventArgs. 2011-05-04 07:41:44 -07:00
Sebastien Pouliot e2f43dd7d5 Fix remaining moon-unit failures wrt Sockets changes
* System.Net.Sockets/Socket_2_1.cs: Ensure RemoteEndPoint is always
available after ConnectAsync (connected or not, allowed or not).
Ensure the Connect event is fired even if denied by policy.
2011-04-28 17:24:49 -04:00
Sebastien Pouliot 05cea06947 Fix copy-paste error in git 17085447
* System.Net.Sockets/Socket_2_1.cs: Fix some moved code (from
SocketAsyncEventArgs.cs) so should the references to RemoteEndPoint
still point to the SocketAsyncEventArgs instance. Fix some moon-unit
test failures
2011-04-28 17:24:49 -04:00
Gonzalo Paniagua Javier 62eac64756 [socket] More BeginConnect (IPAddress []) work
When trying multiple addresses, the second and sucessive calls to
	BeginConnect(IPAddress) will cause an error which we would have to
	ignore and then retry. Since this behavior is not documented, we just
	close the socket and open a new one for retries is there is already a
	pending connect attempt.
2011-04-28 00:03:37 -04:00
Gonzalo Paniagua Javier 72e47eaf71 If there's a delayed exception, clear 'ares' 2011-04-26 23:43:05 -04:00
Gonzalo Paniagua Javier 280d118e66 Worked on linux, failed on OSX 2011-04-26 22:05:24 -04:00
Gonzalo Paniagua Javier 17085447d7 [Socket] Improved ConnectAsync
ConnectAsync() now uses the improved BeginConnect.
2011-04-26 19:45:16 -04:00
Gonzalo Paniagua Javier 47cc2b607d [socket] Fixed other BeginConnect overloads
The BeginConnect overload taking an IPAddress[] was not really
	asynchronous.
2011-04-26 11:02:22 -04:00
Gonzalo Paniagua Javier 9a22cd9cc1 [Socket] Fix BeginConnect
Windows/Linux flagged the socket as writable even when connect() has
	not been called. On *BSD and OSX, this was not the case and we waited
	forever.

	Now, for blocking sockets, we make them blocking and call connect()
	before adding the socket to the wait pool.
2011-04-26 00:03:36 -04:00
Gonzalo Paniagua Javier db66b0e930 Reset BytesTransferred on every reuse. 2011-03-29 13:46:17 -04:00
Sebastien Pouliot f6f6d3e0e5 Fix mono/mcs build for Moonlight profile
* corlib/System.Threading/Timer.cs:
* System/System.Net.Sockets/Socket_2_1.cs:
	Use API available under Moonlight when MOONLIGHT is defined
2011-03-11 16:20:03 -05:00
Gonzalo Paniagua Javier 36d63134e5 [Socket] Remove more auto-delegates 2011-03-10 19:05:17 -05:00
Gonzalo Paniagua Javier cc3d2b03ed [Socket] Minimize allocations of delegates 2011-03-10 19:05:13 -05:00
Gonzalo Paniagua Javier 1a2646196e No need to create an extra instance of Worker. 2011-03-08 12:35:17 -05:00
Jonathan Pryor 1850508c1c Enable UDP Sockets on MOBILE platforms.
Fixes runtime part of #666736.
2011-02-23 23:19:26 -05:00
Sebastien Pouliot 3dbfe75434 Fix parameters names inside System.Net.dll for 2.1 profile
* System.Net/System.Net.Sockets/SocketException_2_1.cs:
* System.Net/System.Net/WebClient_2_1.cs:
* System.Net/System.Net/WebRequest_2_1.cs:
* System/System.Net.Sockets/Socket_2_1.cs:
* System/System.Net/Cookie.cs:
* System/System.Net/DnsEndPoint.cs:
* System/System.Net/EndPoint.cs:
* System/System.Net/IPAddress.cs:
* System/System.Net/IPEndPoint.cs:
* System/System.Net/SocketAddress.cs:
	Remove all red ! from corcompare in System.Net.dll (Silverlight
	4 profile) to make it easier to pinpoint other errors/warnings.
2011-02-15 08:38:06 -05:00
Gonzalo Paniagua Javier bda2b7dc1b [Socket] Fix invalid cast
Fix invalid cast when canceling pending operations due to socket.Close.
2011-02-11 18:36:23 -05:00
Gonzalo Paniagua Javier 891af303aa [Socket] Implemented TCP keep alive support
Implemented SetTcpKeepAlive for ServicePoint*.
2011-01-13 18:28:16 -05:00
Gonzalo Paniagua Javier 91a69045c9 Socket is not connected after error 2011-01-03 21:09:29 -05:00
Michael Hutchinson 32d328ef78 Socket.Dispose is public in 4.0. 2010-12-14 14:20:23 -05:00
Gonzalo Paniagua Javier 98532db21b Don't throw in EndReceive/EndSend + out error
The overloads of EndReceive and EndSend that have an out SocketError
	parameter do not throw.

	Patch by Sven Groot that fixes bug #659056.
2010-12-13 18:56:52 -05:00
Gonzalo Paniagua Javier ba9d007624 [Sockets] Support Remote/LocalEndPoint for AF_UNIX
We were not handling correctly the AF_UNIX family when getting the
	socket name or the peer name.

	Fixes bug #655637.
2010-11-24 00:49:01 -05:00
Marek Safar aad016fd87 Clean up few more warnings 2010-10-15 15:20:25 +01:00
Gonzalo Paniagua Javier 936c28ad16 Handle special case when disposing a socket.
When disposing a socket that has more than one asynchronous read/write
	pending, one of the callbacks could call DisposeAllOnClose() while
	another one is waiting on the lock. Once the lock is acquired,
	queue.Count will be 0 and Dequeue would fail.
	This if fixed now.

	Fixes bug #645675.
2010-10-12 17:30:34 -04:00
Gonzalo Paniagua Javier 0a49cf466c The EndPoint cannot be null
The EndPoint argument in Begin/EndSendTo cannot be null.
2010-10-02 01:41:40 -04:00
Gonzalo Paniagua Javier 2b1a3ea5b6 Handle error in BeginAcceptReceive
We were ignore possible errors when reading after a socket has been
	accepted.
2010-10-02 01:41:39 -04:00
Gonzalo Paniagua Javier 0f7fa8d0dd Schedule the user callback from unmanaged code
When possible, schedule the user callback from unmanaged code. We pass
	it from the IO pool to the regular pool after our internal callback is
	finished.
2010-10-02 01:41:39 -04:00
Gonzalo Paniagua Javier 50a295ac1b Invoke the callback in separate threads
The callbacks need to be invoked in different threads to avoid clogging
	the IO pool.

	Fixes bug #639656.
2010-09-30 01:52:31 -04:00
Sebastien Pouliot 966a4e1990 Fix buffer checks on Socket.[Receive|Send]Async
* System.Net.Sockets/Socket_2_1.cs: Fix, by explicitely throwing an NRE,
the checks in [Receive|Send]Async methods - otherwise an exception would
occur later, on another thread and close the socket (leading to other,
unexpected, exceptions)

* Test/System.Net.Sockets/SocketTest.cs: Add parameter validation test
cases for both ReceiveAsync and SendAsync
2010-09-29 14:33:20 -04:00
Sebastien Pouliot 0999774377 Fix "4762b18c: Fix the moonlight build"
* System.Net.Sockets/Socket_2_1.cs: Do not #id-def out [Receive|Send]
Generic from moonlight build
2010-09-29 14:33:17 -04:00
Sebastien Pouliot 7f2949053b Fix Socket.RemoteEndPoint after ConnectAsync on Moonlight
* System.Net.Sockets/SocketAsyncEventArgs.cs: Set the Socket
RemoteEndPoint to our RemoteEndPoint on Connect operation.
* System.Net.Sockets/Socket_2_1.cs: Return the 'candidate' EndPoint
provided by SocketAsyncEventArgs in ConnectAsync (intead of null)
until the connection is completed.
2010-09-27 20:10:38 -04:00