Commit Graph
146 Commits
Author SHA1 Message Date
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 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
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 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
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 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 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
Gonzalo Paniagua Javier 884680ede3 LocalEndPoint works now for non-blocking connects
We didn't keep the endpoint around for non-blocking connects and later,
	when Poll() was called, we didn't have the information. Also 'isbound'
	wasn't being set in a few places and UDP sockets needed to be marked as
	not connected after a call to Connect() with an Any address.

	Removed an old test for Connect(Any) with UDP sockets, since this is
	used to disconnect them now.

	Fixes bug #640749.
2010-09-22 12:39:07 -04:00
Gonzalo Paniagua Javier 370d27f1df 2010-03-23 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: error handling was totally broken in the synchronous
	Connect() call.  Fixes bug #590488.


svn path=/trunk/mcs/; revision=154087
2010-03-23 20:34:03 +00:00
Miguel de Icaza 87aa9c4de4 Removed a warning; But this loop here looks risky
svn path=/trunk/mcs/; revision=153941
2010-03-20 17:13:31 +00:00
Miguel de Icaza 11ca00c93b 2010-03-19 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153923
2010-03-19 21:46:30 +00:00
Sebastien Pouliot 355a27b73d In System.Timers:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Timer.cs: Removed old NET_2_0 defines and added some new
	MOONLIGHT defines (needed for the client stack)

In System.Net:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* AuthenticationManager.cs: Internal type for Moonlight.
	Add BasicClient, DigestClient, NtlmClient for NET_2_1 since
	this applies to both monotouch and moonlight (client stack).
	Removed unneeded NET_2_0 defines
	* CookieContainer.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* HttpContinueDelegate.cs: Internal type for Moonlight.
	* HttpRequestCreator.cs: Remove a MOONLIGHT define
	* HttpStatusCode.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* HttpWebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight).
	Removed unneeded NET_2_0 and NET_1_1 defines
	* HttpWebResponse.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IAuthenticationModule.cs: Internal type for Moonlight.
	* ICertificatePolicy.cs: Internal type for Moonlight.
	* ICredentialPolicy.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IWebRequestCreate.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* ServicePoint.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* ServicePointManager.cs: Remove a MOONLIGHT define
	* WebException.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* WebHeaderCollection.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* WebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* WebResponse.cs: Internal type for Moonlight. Removed unneeded
	NET_2_0 defines

In System.Net.Sockets:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Socket.cs: Remove some NET_2_0 defines (using) and add a few
	MOONLIGHT defines needed to reuse Socket in the client http stack
	* Socket_2_1.cs: Remove some MOONLIGHT defines
	* SocketAsyncEventArgs.cs: For Moonlight check policy if outside
	System.dll (the client stack use sockets with it's own web 
	xdomain policy)

In System:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Uri.cs: Remove some MOONLIGHT defines

In .:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* moonlight_*_System.dll.sources: Bring extra types so we can
	build a full, managed, internal HTTP stack to be reused for SL3+
	* Makefile: Add a INSIDE_SYSTEM define when compiling System.dll
	to makes it possible to rebuild the same types in System.Net.dll


svn path=/trunk/mcs/; revision=153916
2010-03-19 19:01:31 +00:00
Gonzalo Paniagua Javier 251a6e2610 2009-10-21 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: implement *SendFile().


svn path=/trunk/mcs/; revision=144510
2009-10-21 06:43:39 +00:00
Sebastien Pouliot e0ce50685b 2009-09-27 Sebastien Pouliot <[email protected]>
* SocketAsyncEventArgs.cs: Don't use Socket.Poll for NET_2_1.
	Throw NIE for use of BufferList in Receive.
	* Socket.cs: Move Close(int) to Socket_2_1.cs. Remove NET_2_1
	defines since the file is not used by Moonlight
	* Socket_2_1.cs: Add Close(int) from Socket. Define out Poll
	and Blocking.


svn path=/trunk/mcs/; revision=142722
2009-09-27 14:51:42 +00:00
Gert Driesen 916aaf1dbb * SocketTest.cs: Added tests for argument checks, and improved tests
for disposed socket.
* Socket.cs: Modified some argument names to match MS. Moved disposed
check before argument checks in Receive. Use SocketError.InvalidArgument
instead of using magic numbers. Added back comments that was 
accidentally removed in my previous commit.
* Socket_2_1.cs: Modified some argument names to match MS.

svn path=/trunk/mcs/; revision=137051
2009-06-28 20:39:25 +00:00
Gonzalo Paniagua Javier 2b3a1eaef4 fix the build
svn path=/trunk/mcs/; revision=137049
2009-06-28 16:54:59 +00:00
Gert Driesen ba798b342d * System_test.dll.sources: Added IPv6MulticastOptionTest.cs and
MulticastOptionTest.cs.
* Socket.cs: In GetSocketOption, throw SocketException when (byte [])
option value is null. Use SocketError fields instead of using "magic"
number. In SetSocketOption (SocketOptionLevel, SocketOptionName, object)
only accept Linger, AddMembership, DropMembership and verify option
value.
* MulticastOption.cs: Added argument checks. Save interfaceIndex that is
passed to .ctor, and removed MonoTODO. Renamed arguments to match MS.
Reset InterfaceIndex when LocalAddress is modified, and reset
LocalAddress when InterfaceIndex is modified.
* UdpClient.cs: Modified exception to more closely match MS. Fixed
(int, AddressFamily) .ctor to construct IPv6 endpoint when family is
InterNetworkV6. Added null check for multicastAddr to (IPAddress)
JoinMulticastGroup overload. In (int, IPAddress) and (IPAddress,
IPAddress) overloads of JoinMulticastGroup throw SocketException when
client is IPv4. Added null check for multicastAddr to (IPAddress, int),
overload, and moved JoinMulticastGroup call after argument checks.
* IPv6MulticastOption.cs: Renamed argument names to match MS. Added
null check to set_Group. Added range check to set_InterfaceIndex.
* IPv6MulticastOptionTest.cs: Added .ctor and property tests.
* MulticastOptionTest.cs: Added .ctor and property tests.
* SocketTest.cs: Fixed compiler warnings. Improved tests for
closed socket. Added tests fr GetSocketOption, and SetSocketOption
overloads (for Linger, DontLinger, AddMembership and DropMembership).
* UdpClientTest.cs: Added .ctor and JoinMulticastGroup tests.

svn path=/trunk/mcs/; revision=137048
2009-06-28 16:35:54 +00:00
Gonzalo Paniagua Javier 16d1a86aac 2009-06-27 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: turn WSAEINVAL into ArgumentException.


svn path=/trunk/mcs/; revision=137031
2009-06-27 18:02:46 +00:00
Gonzalo Paniagua Javier 433d127533 2009-06-26 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: MS throws a SocketException in the byte[] overload when
	the value is null.


svn path=/trunk/mcs/; revision=136980
2009-06-26 16:34:20 +00:00
Gonzalo Paniagua Javier eda5c831df 2009-05-11 Gonzalo Paniagua Javier <[email protected]>
* TcpClient.cs:
	* Socket.cs:
	* UdpClient.cs: use GetHostAddresses() instead of Resolve or
	GetHostEntry.


svn path=/trunk/mcs/; revision=133951
2009-05-12 03:56:03 +00:00
Gonzalo Paniagua Javier d4bd43145b 2009-04-30 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: return the last error if a connect to multiple addresses
	fails.


svn path=/trunk/mcs/; revision=133252
2009-05-01 03:28:42 +00:00
Gonzalo Paniagua Javier b252d1787c 2009-04-21 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: End* methods can only be called once per IAsyncResult.
	Bug #466031 fixed.


svn path=/trunk/mcs/; revision=132221
2009-04-21 04:48:42 +00:00
Sebastien Pouliot 68dd206d83 In System.Net.Sockets:
2009-04-09  Sebastien Pouliot  <[email protected]>

	* Socket.cs: Split socket class into two files (this one and the
	new Socket_2_1.cs). This let us remove (some) existing #if in the
	sources and avoid (a lot) of new ones for Moonlight.
	* Socket_2_1.cs: Just enough of socket for NET_2_1. This helps
	the tuner not to bring a lot of extra stuff (some visible)
	into Moonlight.
	* SocketAsyncEventArgs.cs: Ifdef out some cases for NET_2_1 so 
	Moonlight can use it's own (smaller) SocketAsyncOperation enum

In .:
2009-04-09  Sebastien Pouliot  <[email protected]>

	* System.dll.sources: Add System.Net.Sockets/Socket_2_1.cs


svn path=/trunk/mcs/; revision=131392
2009-04-09 15:06:42 +00:00
Gonzalo Paniagua Javier 10badb611a 2009-02-17 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: instead of clearing the sockets form the output and then
	adding them back, we just remove the ones that have not been signaled.
	Fixes bug #354090 and bug #476138.


svn path=/trunk/mcs/; revision=127234
2009-02-18 00:35:48 +00:00
Gonzalo Paniagua Javier 8b0ce39175 reverting this patch until it works with bug 354090 and 476138
svn path=/trunk/mcs/; revision=127104
2009-02-17 07:30:29 +00:00
Gonzalo Paniagua Javier 3ab9dba94e 2009-02-11 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: instead of clearing the sockets form the output and then
	adding them back, we just remove the ones that have not been
	signaled.
	Fixes bug #354090.


svn path=/trunk/mcs/; revision=126637
2009-02-11 19:47:29 +00:00
Gonzalo Paniagua Javier 2be8842ab4 2009-01-19 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: don't throw when there's no ipv6 configuration.


svn path=/trunk/mcs/; revision=123832
2009-01-19 22:25:29 +00:00
Dick Porter 5e0ae0a305 2009-01-09 Dick Porter <[email protected]>
* Socket.cs: Special case 0-length receive requests in the
	BeginAccept overloads that wait for data, so they behave as the
	non-waiting version.  Seems to match MS behaviour, fixes bug
	464201.



svn path=/trunk/mcs/; revision=122904
2009-01-09 15:18:50 +00:00
Bill Holmes b5dde2bbdc 2008-12-30 Bill Holmes <[email protected]>
* socket-io.h : Changing the signature of
	  ves_icall_System_Net_Sockets_Socket_Accept_internal to pass
	  the blocking state.

	* icall-def.h :  Changing the signature of
	  System.Net.Sockets.Socket.Accept_internal to pass the blocking state.

	* socket-io.c (ves_icall_System_Net_Sockets_Socket_Accept_internal) :
	  For Windows only.  Avoid blocking when calling accept by
	  querying for a connection via select.  The loop also queries
	  the thread state every 1000 micro seconds for the thread
	  stop state.  This will avoid the process hanging on shutdown
	  when using a TcpChannel that is never connected to.

	* Socket.cs (Accept_internal) :  Changing the signature to pass
	  the blocking state.
	  
	Code is contributed under MIT/X11 license.


svn path=/trunk/mcs/; revision=122252
2008-12-30 16:58:15 +00:00
Gonzalo Paniagua Javier 09dd5ff790 2008-12-20 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: add a new ReceiveFrom_nocheck that does not throw an
	exception in case of error.


svn path=/trunk/mcs/; revision=121923
2008-12-20 10:52:59 +00:00
Gonzalo Paniagua Javier b12fef3814 2008-12-20 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: if Blocking is set, translate a WouldBlock into a
	TimedOut.


svn path=/trunk/mcs/; revision=121922
2008-12-20 10:04:01 +00:00
Gonzalo Paniagua Javier c25ee5d95b 2008-11-12 Gonzalo Paniagua Javier <[email protected]>
* Socket.cs: mark the socket as not connected when there is a pending
	error or exception about to be thrown.
	Bug #443346 fixed.


svn path=/trunk/mcs/; revision=118696
2008-11-13 03:47:23 +00:00
Bill Holmes 017eaee375 2008-09-10 Bill Holmes <[email protected]>
* Socket.cs : Adding a comment to provide locations where
	  changes to MonoSocketAsyncResult need to be synced.

	* Process.cs : Update the fields of ProcessAsyncReader to
	  match MonoSocketAsyncResult metadata/socket-io.h

	Code is contributed under MIT/X11 license.


svn path=/trunk/mcs/; revision=112681
2008-09-10 15:20:35 +00:00
Atsushi Eno 582b946eb0 2008-09-06 Atsushi Enomoto <[email protected]>
* Socket.cs : (SocketAsyncResult) release byte buffer early so that
	  it does not have to store extra data in pool. Fixed bug #397627.


svn path=/trunk/mcs/; revision=112408
2008-09-05 23:53:42 +00:00
Jb Evain d124c0ef4d ifdef out ResetAbort for SL2
svn path=/trunk/mcs/; revision=109659
2008-08-05 10:45:16 +00:00
Jb Evain e0e4361e63 cleanup System.ComponentModel for SL2
svn path=/trunk/mcs/; revision=109344
2008-07-31 13:49:49 +00:00
Dick Porter d99d4af2ff 2008-06-19 Dick Porter <[email protected]>
* Socket.cs: Implement generic Send() and Receive() methods.
	Fixes bug 395168.

2008-06-19  Dick Porter  <[email protected]>

	* SocketTest.cs: Tests for generic Send() and Receive() methods.



svn path=/trunk/mcs/; revision=106198
2008-06-19 11:50:42 +00:00
Stephane Delcroix 49ee8b5d33 2008-06-12 Stephane Delcroix <[email protected]>
* Socket.cs: minimal changes to run in the 2.1 profile

svn path=/trunk/mcs/; revision=105690
2008-06-12 12:17:50 +00:00
Marek Habersack a0fc121d39 2008-05-09 Marek Habersack <[email protected]>
* SocketAsyncEventArgs.cs: implemented support for executing
	asynchronous socket actions, called from the new xxxxAsync methods
	in Socket. The asynchronous operations do not use the ThreadPool
	as I can't get the sample applications to work (send/receive
	callbacks don't work) - it may change in the future.

	* Socket.cs: implemented several xxxxAsync 2.0sp1 methods. The
	ones not implemented for now are: ReceiveMessageFromAsync and
	SendPacketsAsync. AcceptAsync doesn't perform the check for the
	buffer size for now - need to implement runtime support for that.
	Made several methods internal, so that they can be accessed from
	SocketAsyncEventArgs code.

svn path=/trunk/mcs/; revision=102884
2008-05-09 20:11:09 +00:00