~ubuntu-branches/ubuntu/lucid/mono/lucid

« back to all changes in this revision

Viewing changes to mcs/class/System/System.Net.Sockets/Socket.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer, Jo Shields, Iain Lane, Mirco Bauer
  • Date: 2009-12-14 00:01:59 UTC
  • mfrom: (5.2.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091214000159-3x62t47p9nj4p0sr
Tags: 2.4.3+dfsg-1
[ Jo Shields ]
* debian/monodoc-base.postinst,
  debian/monodoc-base.triggers,
  debian/monodoc-base.install,
  debian/update-monodoc:
  + Add a trigger to handle installation of documentation into monodoc

[ Iain Lane ]
* debian/monodoc-base.postinst: Only update the monodoc index when we need
  to - i.e. when we are being triggered (by a lib installing new docs) or
  upon a new install of monodoc-base (to generate the initial index)

[ Mirco Bauer ]
* The "mince pies for all" release
* New upstream (bugfix) release:
  + New license compiler (lc) tool.
  + Improved memory usage and performance for ASP.NET.
  + Updated xbuild.
  + Many bugfixes.
* debian/control
  debian/rules
  debian/copyright:
  debian/patches/disable_building_RabbitMQ.Client.dll.dpatch:
  + Dropped the RabbitMQ library with spec sources again, as the
    auto-generated API source files without DFSG-free sources for the
    generator are not good enough. (Closes: #560151)
* debian/copyright:
  + Updated for the new license compiler tool.
* debian/rules:
  + Bumped clilibs of libmono-system2.0-cil, libmono-security{1,2}.0-cil,
    libmono-data-tds{1,2}.0-cil and libmono-microsoft-build2.0-cil
    to >= 2.4.3.
* debian/update-monodoc:
  + Handle search index too.
* debian/libmono-profiler.install:
  + Install .so symlinks too, bloody pseudo versioned shared libraries.
* debian/libmono-simd2.0-cil.install:
  + Added missing compile time symlink.
* debian/control:
  + Promote monodoc-viewer from Recommends to Depends for monodoc-manual.
    (Closes: #551909)
  + Fixed typo in monodoc-base and monodoc-manual package description.
    (Closes: #557355, #557379)
  + Bumped Standards-Version to 3.8.3 (no changes needed)
* debian/patches/fix_metadata_dup.dpatch
* debian/patches/fix_gridview_r146128_r146133.dpatch:
  + Dropped, already applied upstream.
* debian/control:
  debian/libmono-cil-dev.install
  debian/*.install:
  + Added new libmono-cil-dev package which ships now all pkg-config files
    and depends on all Mono CLI library packages.
* debian/mono-devel.links:
  + Dropped /usr/bin/csc as it was causing a file conflict with the chicken
    compiler from the chicken-bin package. Most source packages were
    transitioned to use /usr/bin/mono-csc or /usr/bin/cli-csc instead.
    (Closes: #509367, #518106)
* debian/patches/fix_DynamicMethod_restrictedSkipVisibility_r138886.dpatch:
  + Pass restrictedSkipVisibility parameter correctly to the called
    constructor as needed by the DbLinq library. (Closes: #551964)
    (thanks goes to Silviu Paragina for the investigation and the patch)
* debian/mono-xbuild.install
  debian/man/xbuild.1:
  + Replaced xbuild manpage place holder with new upstream manpage.
* debian/mono-xbuild.install:
  + Addded new target files.
* debian/mono-devel.install
  debian/mono-devel.manpages:
  + Added lc tool.
* debian/libmono-system-web2.0-cil.install:
  + Added new development symlinks.
* debian/fix_large_ranges_in_random_generator_r146995.dpatch:
  + Fix random numbers in large ranges.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1961
1961
                        return (BeginSend (buffers, socketFlags, callback, state));
1962
1962
                }
1963
1963
 
1964
 
                [MonoTODO ("Not implemented")]
 
1964
                delegate void SendFileHandler (string fileName, byte [] preBuffer, byte [] postBuffer, TransmitFileOptions flags);
 
1965
 
 
1966
                sealed class SendFileAsyncResult : IAsyncResult {
 
1967
                        IAsyncResult ares;
 
1968
                        SendFileHandler d;
 
1969
 
 
1970
                        public SendFileAsyncResult (SendFileHandler d, IAsyncResult ares)
 
1971
                        {
 
1972
                                this.d = d;
 
1973
                                this.ares = ares;
 
1974
                        }
 
1975
 
 
1976
                        public object AsyncState {
 
1977
                                get { return ares.AsyncState; }
 
1978
                        }
 
1979
 
 
1980
                        public WaitHandle AsyncWaitHandle {
 
1981
                                get { return ares.AsyncWaitHandle; }
 
1982
                        }
 
1983
 
 
1984
                        public bool CompletedSynchronously {
 
1985
                                get { return ares.CompletedSynchronously; }
 
1986
                        }
 
1987
 
 
1988
                        public bool IsCompleted {
 
1989
                                get { return ares.IsCompleted; }
 
1990
                        }
 
1991
 
 
1992
                        public SendFileHandler Delegate {
 
1993
                                get { return d; }
 
1994
                        }
 
1995
 
 
1996
                        public IAsyncResult Original {
 
1997
                                get { return ares; }
 
1998
                        }
 
1999
                }
 
2000
 
1965
2001
                public IAsyncResult BeginSendFile (string fileName,
1966
2002
                                                   AsyncCallback callback,
1967
2003
                                                   object state)
1975
2011
                        if (!File.Exists (fileName))
1976
2012
                                throw new FileNotFoundException ();
1977
2013
 
1978
 
                        throw new NotImplementedException ();
 
2014
                        return BeginSendFile (fileName, null, null, 0, callback, state);
1979
2015
                }
1980
2016
 
1981
 
                [MonoTODO ("Not implemented")]
1982
2017
                public IAsyncResult BeginSendFile (string fileName,
1983
2018
                                                   byte[] preBuffer,
1984
2019
                                                   byte[] postBuffer,
1995
2030
                        if (!File.Exists (fileName))
1996
2031
                                throw new FileNotFoundException ();
1997
2032
 
1998
 
                        throw new NotImplementedException ();
 
2033
                        SendFileHandler d = new SendFileHandler (SendFile);
 
2034
                        return new SendFileAsyncResult (d, d.BeginInvoke (fileName, preBuffer, postBuffer, flags, callback, state));
1999
2035
                }
2000
2036
#endif
2001
2037
 
2502
2538
                }
2503
2539
 
2504
2540
#if NET_2_0
2505
 
                [MonoTODO]
2506
2541
                public void EndSendFile (IAsyncResult asyncResult)
2507
2542
                {
2508
2543
                        if (disposed && closed)
2511
2546
                        if (asyncResult == null)
2512
2547
                                throw new ArgumentNullException ("asyncResult");
2513
2548
 
2514
 
                        SocketAsyncResult req = asyncResult as SocketAsyncResult;
2515
 
                        if (req == null)
 
2549
                        SendFileAsyncResult ares = asyncResult as SendFileAsyncResult;
 
2550
                        if (ares == null)
2516
2551
                                throw new ArgumentException ("Invalid IAsyncResult", "asyncResult");
2517
2552
 
2518
 
                        if (Interlocked.CompareExchange (ref req.EndCalled, 1, 0) == 1)
2519
 
                                throw InvalidAsyncOp ("EndSendFile");
2520
 
                        throw new NotImplementedException ();
 
2553
                        ares.Delegate.EndInvoke (ares.Original);
2521
2554
                }
2522
2555
#endif
2523
2556
 
3402
3435
                }
3403
3436
 
3404
3437
#if NET_2_0
3405
 
                [MonoTODO ("Not implemented")]
 
3438
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
 
3439
                private extern static bool SendFile (IntPtr sock, string filename, byte [] pre_buffer, byte [] post_buffer, TransmitFileOptions flags);
 
3440
 
3406
3441
                public void SendFile (string fileName)
3407
3442
                {
3408
3443
                        if (disposed && closed)
3414
3449
                        if (!blocking)
3415
3450
                                throw new InvalidOperationException ();
3416
3451
 
3417
 
                        if (!File.Exists (fileName))
3418
 
                                throw new FileNotFoundException ();
3419
 
 
3420
 
                        /* FIXME: Implement TransmitFile */
3421
 
                        throw new NotImplementedException ();
 
3452
                        SendFile (fileName, null, null, 0);
3422
3453
                }
3423
3454
 
3424
 
                [MonoTODO ("Not implemented")]
3425
3455
                public void SendFile (string fileName, byte[] preBuffer, byte[] postBuffer, TransmitFileOptions flags)
3426
3456
                {
3427
3457
                        if (disposed && closed)
3433
3463
                        if (!blocking)
3434
3464
                                throw new InvalidOperationException ();
3435
3465
 
3436
 
                        if (!File.Exists (fileName))
3437
 
                                throw new FileNotFoundException ();
3438
 
 
3439
 
                        /* FIXME: Implement TransmitFile */
3440
 
                        throw new NotImplementedException ();
 
3466
                        if (!SendFile (socket, fileName, preBuffer, postBuffer, flags)) {
 
3467
                                SocketException exc = new SocketException ();
 
3468
                                if (exc.ErrorCode == 2 || exc.ErrorCode == 3)
 
3469
                                        throw new FileNotFoundException ();
 
3470
                                throw exc;
 
3471
                        }
3441
3472
                }
3442
3473
 
3443
3474
                public bool SendToAsync (SocketAsyncEventArgs e)
3570
3601
                        if (disposed && closed)
3571
3602
                                throw new ObjectDisposedException (GetType ().ToString ());
3572
3603
 
 
3604
                        // I'd throw an ArgumentNullException, but this is what MS does.
 
3605
                        if (opt_value == null)
 
3606
                                throw new SocketException (10014, "Error trying to dereference an invalid pointer");
 
3607
                        
3573
3608
                        int error;
3574
3609
                        
3575
3610
                        SetSocketOption_internal(socket, level, name, null,
3576
3611
                                                 opt_value, 0, out error);
3577
3612
 
3578
 
                        if (error != 0)
 
3613
                        if (error != 0) {
 
3614
                                if (error == 10022) // WSAEINVAL
 
3615
                                        throw new ArgumentException ();
3579
3616
                                throw new SocketException (error);
 
3617
                        }
3580
3618
                }
3581
3619
 
3582
3620
                public void SetSocketOption (SocketOptionLevel level, SocketOptionName name, int opt_value)
3599
3637
                        if (disposed && closed)
3600
3638
                                throw new ObjectDisposedException (GetType ().ToString ());
3601
3639
 
 
3640
                        // NOTE: if a null is passed, the byte[] overload is used instead...
3602
3641
                        if (opt_value == null)
3603
3642
                                throw new ArgumentNullException("opt_value");
3604
3643
                        
3623
3662
                                SetSocketOption_internal (socket, level, name, opt_value, null, 0, out error);
3624
3663
                        }
3625
3664
 
3626
 
                        if (error != 0)
 
3665
                        if (error != 0) {
 
3666
                                if (error == 10022) // WSAEINVAL
 
3667
                                        throw new ArgumentException ();
3627
3668
                                throw new SocketException (error);
 
3669
                        }
3628
3670
                }
3629
3671
 
3630
3672
#if NET_2_0
3636
3678
                        int error;
3637
3679
                        int int_val = (optionValue) ? 1 : 0;
3638
3680
                        SetSocketOption_internal (socket, level, name, null, null, int_val, out error);
3639
 
                        if (error != 0)
 
3681
                        if (error != 0) {
 
3682
                                if (error == 10022) // WSAEINVAL
 
3683
                                        throw new ArgumentException ();
3640
3684
                                throw new SocketException (error);
 
3685
                        }
3641
3686
                }
3642
3687
#endif
3643
3688
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
3679
3724
                                closed = true;
3680
3725
                                IntPtr x = socket;
3681
3726
                                socket = (IntPtr) (-1);
 
3727
                                Thread th = blocking_thread;
 
3728
                                if (th != null) {
 
3729
                                        th.Abort ();
 
3730
                                        blocking_thread = null;
 
3731
                                }
 
3732
 
3682
3733
                                Close_internal (x, out error);
3683
 
                                if (blocking_thread != null) {
3684
 
                                        blocking_thread.Abort ();
3685
 
                                        blocking_thread = null;
3686
 
                                }
3687
 
 
3688
3734
                                if (error != 0)
3689
3735
                                        throw new SocketException (error);
3690
3736
                        }