/[dotgnu-pnet]/pnetlib/System/Net/Sockets/Socket.cs
ViewVC logotype

Diff of /pnetlib/System/Net/Sockets/Socket.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by drobosson, Mon Feb 21 12:22:59 2005 UTC revision 1.23 by Rich333, Fri Feb 25 19:14:58 2005 UTC
# Line 113  public class Socket : IDisposable Line 113  public class Socket : IDisposable
113                                  if(!SocketMethods.Create((int)addressFamily, (int)socketType,                                  if(!SocketMethods.Create((int)addressFamily, (int)socketType,
114                                                                                   (int)protocolType, out handle))                                                                                   (int)protocolType, out handle))
115                                  {                                  {
116                                          throw new SocketException(SocketMethods.GetErrno());                                          throw new SocketException(this.GetErrno());
117                                  }                                  }
118                          }                          }
119          private Socket(AddressFamily addressFamily, SocketType socketType,          private Socket(AddressFamily addressFamily, SocketType socketType,
# Line 145  public class Socket : IDisposable Line 145  public class Socket : IDisposable
145                                  GC.SuppressFinalize(this);                                  GC.SuppressFinalize(this);
146                          }                          }
147    
148            // Get the current errno condition.
149            private Errno GetErrno()
150                            {
151                                    // get the errno condition
152                                    Errno errno = SocketMethods.GetErrno();
153    
154                                    // disconnect as required
155                                    switch(errno)
156                                    {
157                                            case Errno.EPIPE:
158                                            case Errno.ECONNABORTED:
159                                            case Errno.ECONNRESET:
160                                            case Errno.ETIMEDOUT:
161                                            case Errno.ECONNREFUSED:
162                                            case Errno.EHOSTDOWN:
163                                            {
164                                                    connected = false;
165                                            }
166                                            break;
167                                    }
168    
169                                    // return the errno condition
170                                    return errno;
171                            }
172    
173          // Accept an incoming connection on this socket.          // Accept an incoming connection on this socket.
174          public Socket Accept()          public Socket Accept()
175                          {                          {
# Line 174  public class Socket : IDisposable Line 199  public class Socket : IDisposable
199                                  if(!SocketMethods.Accept                                  if(!SocketMethods.Accept
200                                            (currentHandle, addrReturn, out newHandle))                                            (currentHandle, addrReturn, out newHandle))
201                                  {                                  {
202                                          throw new SocketException(SocketMethods.GetErrno());                                          throw new SocketException(this.GetErrno());
203                                  }                                  }
204    
205                                  // Create the end-point object for the remote side.                                  // Create the end-point object for the remote side.
# Line 659  public class Socket : IDisposable Line 684  public class Socket : IDisposable
684                                          // Bind the address to the socket.                                          // Bind the address to the socket.
685                                          if(!SocketMethods.Bind(handle, addr))                                          if(!SocketMethods.Bind(handle, addr))
686                                          {                                          {
687                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
688                                          }                                          }
689    
690                                          // Record the local end point for later.                                          // Record the local end point for later.
# Line 703  public class Socket : IDisposable Line 728  public class Socket : IDisposable
728                                          // Connect to the foreign location.                                          // Connect to the foreign location.
729                                          if(!SocketMethods.Connect(handle, addr))                                          if(!SocketMethods.Connect(handle, addr))
730                                          {                                          {
731                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
732                                          }                                          }
733                                          connected = true;                                          connected = true;
734                                          this.remoteEP = remoteEP;                                          this.remoteEP = remoteEP;
# Line 745  public class Socket : IDisposable Line 770  public class Socket : IDisposable
770                                                          (handle, (int)optionLevel, (int)optionName,                                                          (handle, (int)optionLevel, (int)optionName,
771                                                           out optionValue))                                                           out optionValue))
772                                          {                                          {
773                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
774                                          }                                          }
775                                          return optionValue;                                          return optionValue;
776                                  }                                  }
# Line 785  public class Socket : IDisposable Line 810  public class Socket : IDisposable
810                                                                          (handle, out enabled, out seconds))                                                                          (handle, out enabled, out seconds))
811                                                          {                                                          {
812                                                                  throw new SocketException                                                                  throw new SocketException
813                                                                          (SocketMethods.GetErrno());                                                                          (this.GetErrno());
814                                                          }                                                          }
815                                                          return ((enabled && seconds == 0) ? 1 : 0);                                                          return ((enabled && seconds == 0) ? 1 : 0);
816                                                  }                                                  }
# Line 804  public class Socket : IDisposable Line 829  public class Socket : IDisposable
829                                                                          (handle, out enabled, out seconds))                                                                          (handle, out enabled, out seconds))
830                                                          {                                                          {
831                                                                  throw new SocketException                                                                  throw new SocketException
832                                                                          (SocketMethods.GetErrno());                                                                          (this.GetErrno());
833                                                          }                                                          }
834                                                          return new LingerOption(enabled, seconds);                                                          return new LingerOption(enabled, seconds);
835                                                  }                                                  }
# Line 860  public class Socket : IDisposable Line 885  public class Socket : IDisposable
885                                                                           group, mcint))                                                                           group, mcint))
886                                                          {                                                          {
887                                                                  throw new SocketException                                                                  throw new SocketException
888                                                                          (SocketMethods.GetErrno());                                                                          (this.GetErrno());
889                                                          }                                                          }
890                                                          return new MulticastOption                                                          return new MulticastOption
891                                                                  ((new SocketAddress(group)).IPAddress,                                                                  ((new SocketAddress(group)).IPAddress,
# Line 900  public class Socket : IDisposable Line 925  public class Socket : IDisposable
925                                                  if(!SocketMethods.DiscoverIrDADevices(handle, data))                                                  if(!SocketMethods.DiscoverIrDADevices(handle, data))
926                                                  {                                                  {
927                                                          throw new SocketException                                                          throw new SocketException
928                                                                  (SocketMethods.GetErrno());                                                                  (this.GetErrno());
929                                                  }                                                  }
930                                                  return data;                                                  return data;
931                                          }                                          }
# Line 937  public class Socket : IDisposable Line 962  public class Socket : IDisposable
962                                          // Perform a listen on the socket.                                          // Perform a listen on the socket.
963                                          if(!SocketMethods.Listen(handle, backlog))                                          if(!SocketMethods.Listen(handle, backlog))
964                                          {                                          {
965                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
966                                          }                                          }
967                                  }                                  }
968                          }                          }
# Line 991  public class Socket : IDisposable Line 1016  public class Socket : IDisposable
1016                                  }                                  }
1017                                  else if(result < 0)                                  else if(result < 0)
1018                                  {                                  {
1019                                          throw new SocketException(SocketMethods.GetErrno());                                          throw new SocketException(this.GetErrno());
1020                                  }                                  }
1021                                  else                                  else
1022                                  {                                  {
# Line 1020  public class Socket : IDisposable Line 1045  public class Socket : IDisposable
1045                                                  (handle, buffer, offset, size, (int)socketFlags);                                                  (handle, buffer, offset, size, (int)socketFlags);
1046                                          if(result < 0)                                          if(result < 0)
1047                                          {                                          {
1048                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1049                                          }                                          }
1050                                          else                                          else
1051                                          {                                          {
# Line 1084  public class Socket : IDisposable Line 1109  public class Socket : IDisposable
1109                                                   (int)socketFlags, addrReturn);                                                   (int)socketFlags, addrReturn);
1110                                          if(result < 0)                                          if(result < 0)
1111                                          {                                          {
1112                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1113                                          }                                          }
1114                                          else                                          else
1115                                          {                                          {
# Line 1342  public class Socket : IDisposable Line 1367  public class Socket : IDisposable
1367                                                  (handle, buffer, offset, size, (int)socketFlags);                                                  (handle, buffer, offset, size, (int)socketFlags);
1368                                          if(result < 0)                                          if(result < 0)
1369                                          {                                          {
1370                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1371                                          }                                          }
1372                                          else                                          else
1373                                          {                                          {
# Line 1404  public class Socket : IDisposable Line 1429  public class Socket : IDisposable
1429                                                  (handle, buffer, offset, size, (int)socketFlags, addr);                                                  (handle, buffer, offset, size, (int)socketFlags, addr);
1430                                          if(result < 0)                                          if(result < 0)
1431                                          {                                          {
1432                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1433                                          }                                          }
1434                                          else                                          else
1435                                          {                                          {
# Line 1453  public class Socket : IDisposable Line 1478  public class Socket : IDisposable
1478                                                          (handle, (int)optionLevel, (int)optionName,                                                          (handle, (int)optionLevel, (int)optionName,
1479                                                           optionValue))                                                           optionValue))
1480                                          {                                          {
1481                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1482                                          }                                          }
1483                                  }                                  }
1484                          }                          }
# Line 1573  public class Socket : IDisposable Line 1598  public class Socket : IDisposable
1598                                                                           linger.LingerTime))                                                                           linger.LingerTime))
1599                                                          {                                                          {
1600                                                                  throw new SocketException                                                                  throw new SocketException
1601                                                                          (SocketMethods.GetErrno());                                                                          (this.GetErrno());
1602                                                          }                                                          }
1603                                                  }                                                  }
1604                                                  return;                                                  return;
# Line 1610  public class Socket : IDisposable Line 1635  public class Socket : IDisposable
1635                                                                           group, mcint))                                                                           group, mcint))
1636                                                          {                                                          {
1637                                                                  throw new SocketException                                                                  throw new SocketException
1638                                                                          (SocketMethods.GetErrno());                                                                          (this.GetErrno());
1639                                                          }                                                          }
1640                                                  }                                                  }
1641                                                  return;                                                  return;
# Line 1631  public class Socket : IDisposable Line 1656  public class Socket : IDisposable
1656                                          }                                          }
1657                                          if(!SocketMethods.Shutdown(handle, (int)how))                                          if(!SocketMethods.Shutdown(handle, (int)how))
1658                                          {                                          {
1659                                                  throw new SocketException(SocketMethods.GetErrno());                                                  throw new SocketException(this.GetErrno());
1660                                          }                                          }
1661                                  }                                  }
1662                          }                          }
# Line 1679  public class Socket : IDisposable Line 1704  public class Socket : IDisposable
1704                                                  if(result < 0)                                                  if(result < 0)
1705                                                  {                                                  {
1706                                                          throw new SocketException                                                          throw new SocketException
1707                                                                  (SocketMethods.GetErrno());                                                                  (this.GetErrno());
1708                                                  }                                                  }
1709                                                  else                                                  else
1710                                                  {                                                  {
# Line 1796  public class Socket : IDisposable Line 1821  public class Socket : IDisposable
1821                                                  if(!SocketMethods.GetSockName(handle, addrReturn))                                                  if(!SocketMethods.GetSockName(handle, addrReturn))
1822                                                  {                                                  {
1823                                                          throw new SocketException                                                          throw new SocketException
1824                                                                  (SocketMethods.GetErrno());                                                                  (this.GetErrno());
1825                                                  }                                                  }
1826    
1827                                                  // Create a new end-point object using addrReturn.                                                  // Create a new end-point object using addrReturn.

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26