Commit Graph
160 Commits
Author SHA1 Message Date
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
Andres G. Aragoneses 67f528d7bb [Socket] Improve exception message when timing out in Socket.cs
This uses now the same exception message as MS.NET.
2013-04-08 10:42:42 +01:00
Andres G. Aragoneses 2ee016a7a6 [Socket] Refactor Socket to make Receive(_) call Receive(_,_)
After previous commit, two Receive() overloads are basically the same, so
we can remove some duplicated code here by making one call the other one.
2013-04-08 10:41:56 +01:00
Andres G. Aragoneses 55c7e30b1e [Socket] Specify 'timeout' in the exception msg of Receive(buf)
In the same way the overload Receive (buf, flags) already does, mention
"time out" in the exception message when the socketError is WOULDBLOCK and
the socket is not non-blocking (otherwise it would throw with the reason
"Operation on non-blocking socket would block", which doesn't make sense
for a socket that is not non-blocking).
2013-04-08 10:41:18 +01:00
Torello Querci 0624fa42f1 Fix for bug 10233 about Socket.BeginSendFile 2013-03-01 14:30:04 +01:00
Rodrigo Kumpera 5007c14d62 Kill the MOONLIGHT define in System. 2013-02-11 13:01:11 -05:00
Paolo Molaro 452aaf4e5b Fixes xambug#2965: enqueue the correct worker instance (change from Tammo Hinrichs). 2012-08-02 18:10:23 +02: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
Duncan Mak 20bf543db3 Add missing semicolon to fix the build. 2012-04-30 00:28:42 -04:00
JamesB7 23df5e1d5b Fixed a typo and a whitespacing mistake.
Also made CheckRange more descriptive - no performance loss since the conditions were ORed before and so both got checked anyway.
2012-04-29 19:40:38 -03:00
JamesB7 d9d66c6465 Finished making the changes.
There are two types of checks that were being done before:
(1) offset < 0? size < 0? offset + size > buffer.Length? This is trivial to get around. If I make both offset and size positive but have the sum overflow, it will pass all three checks.

(2) offset in range? size in range? If the buffer is very large this might run into overflow issues with its checking, though fine most of the time...

Is the offset in range? And is the size in range against buffer.Length - offset (which we know to be >= 0 from the earlier offset check)? This method of bounds checking is not in any danger from two's complement overflows.
2012-04-29 19:34:47 -03:00
JamesB7 c03eccac3c Fix for two's complement overflow. Doing it just for BeginReceive first in case GitHub's code editor screws up again. 2012-04-29 19:15:14 -03: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
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