Commit Graph
280 Commits
Author SHA1 Message Date
Gonzalo Paniagua Javier b96b00cb9d Internal worker is kept while there is an ongoing operation
When there is an ongoing operation we can't dispose the internal
	worker because it might be used by the IO threadpool.

	Fixes Novell bug #691076 and Xamarin bug #766.
2011-09-13 00:01:38 -04:00
Bassam Tabbara 1d51e7ac60 Networkstream now throws IOException('connection closed') if the socket was closed/disposed 2011-08-07 23:17:19 -07: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 cef86e8e61 Made Count setter internal ->
Set Count to 0 as well as BytesTransferred when reusing a SocketAsyncEventArgs
2011-05-04 07:44:55 -07: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 b48b443f6c Reset the blocking flag as soon as possible. 2011-04-26 11:02:23 -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
Miguel de Icaza 68bbc4c2d7 Do not build the Socket passing on Mobile systems 2011-01-20 22:44:27 -05:00
Miguel de Icaza 5b065d9878 [sockets] Implement DuplicateAndClose and Socket (SocketInformation) constructor for in-process socket passing (AppDomains) 2011-01-20 16:53:41 -05:00
Gonzalo Paniagua Javier 891af303aa [Socket] Implemented TCP keep alive support
Implemented SetTcpKeepAlive for ServicePoint*.
2011-01-13 18:28:16 -05:00
Zoltan Varga b99bbf419f Change some usages of ArrayList to List<T> to avoid calls to the slow ArrayList.ToArray(Type) method. 2011-01-06 13:17:01 +01: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 e5074473d6 Handle closed sockets in the callbacks
Accept returns a Socket in AcceptSocket even when the listener is closed.
	Handle ObjectDisposedException for the other callbacks.

	Fixes bug #657593.
2010-12-04 23:29:14 -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
Sebastien Pouliot e8de8115ad Remove outdated MonoTODO
* SocketAsyncEventArgs.cs: Remove TODO on SocketClientAccessPolicy
Protocol property
2010-10-13 13:03:40 -04: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 31485d3ee7 [moon] Move policy restriction / elevated trust check outside of loop
* System.Net.Sockets/SocketAsyncEventArgs.cs: Move policy restriction
and elevated trust check outside of loop since its value won't change
based on the ipaddress
2010-09-29 14:33:19 -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
Jb Evain 4762b18c11 Fix the moonlight build 2010-09-27 16:12:08 +02:00
Gonzalo Paniagua Javier 145726835e Set LastOperation properly
SocketAsyncEventArgs.LastOperation is set when the operation is
	invoked.
	Reset the error status before each new *Async() call.
2010-09-27 00:27:04 -04:00
Gonzalo Paniagua Javier 430b2940bd Bypass BeginInvoke for asynch. operations
The code involved in a delegate BeginInvoke is too heavy and of no use
	for socket asynchronous operations. With these changes, we bypass all
	that and send the work items directly to the asynchronous IO queue,
	improving performance and lowering memory use.
2010-09-26 01:58:38 -04:00
Gonzalo Paniagua Javier 2d0c85f412 ConnectAsync() security checks
-ConnectAsync() changed to make security checks for all endpoints before
	trying to connect for the first time.
	-Use the socket Connect() call instead of repeating the same stuff.
	Connect should be splitted in 2 pieces (DNS + Connection attempts).
2010-09-25 18:37:30 -04:00
Gonzalo Paniagua Javier 3ed061749e Added support for ArraySegment
-Removed NET_2_0
	-Implemented support for the Receive/Send overloads that take a list of
	ArraySegments.
2010-09-25 18:37:30 -04:00
Gonzalo Paniagua Javier f3463e7232 Made the moonlight profile happy.
Disabled operations not allowed under moonlight.
2010-09-25 14:08:13 -04:00
Gonzalo Paniagua Javier 3419c3ffc8 Move async IO code to Socket_2_1
Moved internal classes to Socket_2_1.
2010-09-25 12:48:55 -04:00
Gonzalo Paniagua Javier 61d0f84376 Rework SocketAsyncEventArgs internals
-Removed #if NET_2_0
	-All the *Async() calls but ConnectAsync() are routed through the
	asynch IO threadpool instead of creating a new short-lived thread for
	every operation.
	-When reusing a SocketAsyncEventArgs only 1 new object, a delegate, is
	created.
2010-09-25 12:37:27 -04:00