63 Commits
Author SHA1 Message Date
Martin Baulig 1256d6c8cf Use NetworkStream from CoreFX. (#16889)
* Use `NetworkStream` from CoreFX.

This brings the `NetworkStream` class and related tests from CoreFX.

* `SocketAsyncEventArgs`: partially replace the following properties
  with the CoreFX version: `Buffer`, `BufferList`, `Offset`, `SetBuffer ()`
  as well as the internal `CopyBufferFrom ()`.

* `SocketAsyncResult`: change `Buffer` from `byte[]` to `Memory<byte>`.

* Add internal `Socket` overloads:
   - `Receive (Memory<byte> buffer, int, int, SocketFlags, out SocketError)`
   - `ReceiveFrom (Memory<byte>, int, int, SocketFlags, ref EndPoint, out SocketError)`
   - `SendTo (Memory<byte>, int, int, SocketFlags, EndPoint)`

* Implement async task overloads from CoreFX (`Socket.Tasks.cs`) to `Socket`:
   - `int Read(Span<byte>)`
   - `Task<int> ReadAsync(byte[], int, int, CancellationToken)`
   - `ValueTask<int> ReadAsync(Memory<byte>, CancellationToken)`
   - `int ReadByte()`
   - `void Write(ReadOnlySpan<byte>)`
   - `Task WriteAsync(byte[], int, int, CancellationToken)`
   - `ValueTask WriteAsync(ReadOnlyMemory<byte>, CancellationToken)`
   - `void WriteByte(byte)`

* remove internal unused `PooledStream` and `ConnectionPool` APIs.

* bring new tests from CoreFX:
  - `System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs`
  - `System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.netcoreapp.cs`

* corlib: add `System.IO.FileSystem` and `System.Net.Sockets` resources and update SR.

* Update Socket.cs

* [csproj] Update project files

* Bump API snapshot submodule
2019-09-19 14:46:29 +02:00
Martin Baulig 1c13b30225 SocketAsyncEventArgs cleanups and preparations for the real thing. (#16001)
Cleaning up the `SocketAsyncEventArgs` class and preparing it for it's eventual
adaption from CoreFX.

There are a few instance fields and property accessors with `internal` visibility,
which the CoreFX version does not have.  Replaced these with accessor methods.

The `PolicyRestricted` property and it's related `SocketAsyncEventArgs (bool)`
constructor is not used anywhere and the CoreFX version has a constructor with the
same signature, but different semantics.

In the CoreFX version, `Complete ()` does not call `DoComplete (this)` - renamed it
into `Complete_internal ()` to avoid any ambiguities and help the transitioning.
2019-08-06 12:13:40 +02:00
Martin Baulig 6818163383 Use MultipleConnectAsync from CoreFX. (#15972)
* Use `MultipleConnectAsync` from CoreFX.

* [csproj] Update project files
2019-08-02 15:10:03 -04:00
Egor Bogatov cf69b47259 NS2.1: System.IO, System.Reflection.Emit, etc (#12854)
* System.IO, System.Data

* lots of small ns21 improvements

* More changes (System.Reflection.Emit)

* Add IEquatable to S.R.Emit types

* bump corefx

* fix unix build

* more NS21 changes

* more changes

* bump corefx

* Fix failing tests (Sockets)

* bump corefx

* tmp workaround

* move DispatchProxyGenerator to net_4_x

* Bump API snapshot submodule

* [csproj] Update project files
2019-02-14 22:40:58 +01:00
Egor Bogatov 534c98c070 [NS2.1] More types and members (#11944)
* Add NS21 Events to EventListener

* NS21: System.Data.DbProviderFactories

* Add ISOWeek

* some Socket API, etc

* more ns21 members

* Add GC.GetAllocatedBytesForCurrentThread stub

* clean up in icall-def.h

* bump corert

* Bump API snapshot submodule

* [csproj] Update project files
2018-12-21 10:37:22 +01:00
Martin Baulig 626ac86a03 [System]: Fix another SocketAsyncEventArgs issue for #8871. (#8938) 2018-06-13 10:18:27 +02:00
EgorBo fbb7c4d877 make SocketAsyncEventArgs reusable 2018-05-29 08:18:47 +02:00
Alexander Köplinger ad5703adfd [System] Set exception on Finish*Failure in SocketAsyncEventArgs (#6462)
Follow up to https://github.com/mono/mono/pull/6431, we should
capture the exception that is passed to the methods.

Copied the SetResult() method that referencesource uses.
2018-01-09 15:45:47 +01:00
Miguel de Icaza 406b40bb77 Implement a couple of SocketAsyncEventArgs methods 2018-01-08 13:18:19 +01:00
Martin Baulig d62228e521 [System]: Don't call OnCompleted(this) twice in SocketAsyncEventArgs.FinishWrapperConnectSuccess(). (#4894) 2017-05-23 15:42:05 -04:00
Marek Safar 7f06a0910e [System] Implements Socket::ConnectAsync. Fixes #44406 2016-10-18 17:14:59 +02:00
Marek Safar 4d3402deed [System] SocketAsyncEventArgs::Dispose does not free any managed resources. Fixes #44757 2016-10-13 16:44:39 +02:00
Alexander Köplinger 112631f5c6 [bcl] Add missing APIs for netstandard parity and expose a few APIs on mobile
This ensures we're compliant with the upcoming netstandard2.0 API surface area.
2016-09-23 17:50:06 +02:00
Ludovic Henry 249daf43de [mcs] Replace NET_2_1 by MOBILE
NET_2_1 is also defined whenever we define MOBILE, so they have the same effect. Silverlight was 2.1 but it's been dead for a while now, and we do not even support it.
2016-08-18 16:34:36 +02:00
Alexander Köplinger 3c3ef17376 [bcl] Update to match NETStandard 1.6 members 2016-08-11 20:53:38 +02:00
Ludovic Henry e5e97eafef [socket] Refactor SocketAsyncEventArgs creation 2015-10-05 18:49:19 +01:00
Ludovic Henry 801b3ffcd3 [socket] Move callbacks out of SocketAsyncEventArgs 2015-10-05 18:49:19 +01:00
Ludovic Henry 19f7162390 [socket] Remove SocketAsyncWorker
By having the callbacks directly in Socket, we can remove the SocketAsyncWorker class. This also greatly simplify this part of the code, as the callbacks are at the same place as the Begin/End invokes.
2015-10-05 18:49:19 +01:00
Ludovic Henry d088bf0593 [socket] Remove SocketAsyncEventArgs.Dispatcher 2015-10-05 18:49:19 +01:00
Ludovic Henry 333a93ab7b [Socket] Cleanup of SocketAsyncWorker, SocketAsyncResult and SocketAsyncEventArgs 2015-04-09 15:41:27 +01:00
Ludovic Henry 6c72a6e005 [Socket] Move Worker out of Socket_2_1.cs to SocketAsyncWorker.cs 2015-04-08 18:25:13 +01:00
Ludovic Henry ecc6abaf6d [Socket] Move SocketOperation out of Socket_2_1.cs 2015-04-08 17:38:44 +01:00
Marcos Henrich 5194d5689e [System] Socket.socket is now a SafeSocketHandle. 2015-03-02 14:32:53 +00:00
Zoltan Varga 032f313d5f [bcl] Remove NET_4_0 defines from class libs. 2015-01-13 16:06:31 -05:00
michaldobrodenka 7174b069cf Fix for ObjectDiposedException in DispatcherCB class
https://bugzilla.xamarin.com/show_bug.cgi?id=23700
2014-10-27 13:28:59 +01:00
Ed Boren 0c55c45450 ConnectCallback needs to call EndConnect
Socket.ConnectAsync uses BeginConnect, and ends here in
ConnectCallback. It needs to call EndConnect so any error can be
propagated up.

See Xamarin bug: https://bugzilla.xamarin.com/show_bug.cgi?id=21017
2014-07-07 13:25:51 -04:00
Robert Pickering fb2f5e0a2f Allow .NET 4.0 + users to use the ConnectSocket property 2014-04-24 07:34:27 +02:00
Rodrigo Kumpera 5007c14d62 Kill the MOONLIGHT define in System. 2013-02-11 13:01:11 -05:00
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
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
Gonzalo Paniagua Javier 17085447d7 [Socket] Improved ConnectAsync
ConnectAsync() now uses the improved BeginConnect.
2011-04-26 19:45:16 -04:00
Gonzalo Paniagua Javier db66b0e930 Reset BytesTransferred on every reuse. 2011-03-29 13:46:17 -04:00
Gonzalo Paniagua Javier 36d63134e5 [Socket] Remove more auto-delegates 2011-03-10 19:05:17 -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
Sebastien Pouliot e8de8115ad Remove outdated MonoTODO
* SocketAsyncEventArgs.cs: Remove TODO on SocketClientAccessPolicy
Protocol property
2010-10-13 13:03:40 -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 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
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 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 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
Sebastien Pouliot 240f7e8f1d update System.Net.dll for SL4 API
svn path=/trunk/mcs/; revision=155874
2010-04-21 14:03:45 +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
Jb Evain ba61ae505e use MOONLIGHT symbol
svn path=/trunk/mcs/; revision=153655
2010-03-16 12:07:46 +00:00
Sebastien Pouliot c54a75466f In System/System.Net.Sockets:
2010-03-10  Sebastien Pouliot  <[email protected]>

	* SocketAsyncEventArgs.cs: Remove the use of reflection to check
	xdomain poilicy on sockets (since the policy code now resides in
	System.Net.dll)

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

	* net_2_1_raw_System.Net.dll.sources: Add types from (new internal)
	System.Net.Policy (moved from System.Windows.Browser.dll)
	* Makefile: Add reference to System.Xml.dll to parse policies

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

	* BaseDomainPolicy.cs, ClientAccessPolicy[Parser].cs, 
	CrossDomainPolicyManager.cs, FlashCrossDomainPolicy[Parser].cs,
	ICrossDomainPolicy.cs, NoAccessPolicy.cs, PolicyDownloadPolicy.cs,
	SiteOfOriginPolicy.cs: Moved from System.Net.dll with namespace 
	and minor build adjustments.


svn path=/trunk/mcs/; revision=153396
2010-03-10 13:19:46 +00:00
Sebastien Pouliot 33bb7e756a 2010-01-21 Sebastien Pouliot <[email protected]>
* SocketAsyncEventArgs.cs: Apply Gendarme's ProtectCallToEventDelegatesRule


svn path=/trunk/mcs/; revision=150033
2010-01-22 01:50:48 +00:00
Sebastien Pouliot f2a2bf9ffb move DnsEndPoint to ease 4.0
svn path=/trunk/mcs/; revision=147700
2009-12-04 20:16:55 +00:00
Sebastien Pouliot e818e02eee 2009-11-03 Sebastien Pouliot <[email protected]>
* SocketAsyncEventArgs.cs: Set error back to SocketError.Success
	once CheckEndPoint succeed.
	[Fix bug #549586]


svn path=/trunk/mcs/; revision=145329
2009-11-03 21:57:55 +00:00
Sebastien Pouliot 2763f57c1c 2009-09-28 Sebastien Pouliot <[email protected]>
* SocketAsyncEventArgs.cs: Default SocketError.AccessDenied on 
	Connect in case none of the DnsEndPoint provides an adequate 
	address (family).


svn path=/trunk/mcs/; revision=142746
2009-09-28 12:02:47 +00:00