1 // System.Net.Sockets.Socket.cs
4 // Phillip Pearson (pp@myelin.co.nz)
6 // Copyright (C) 2001, Phillip Pearson
7 // http://www.myelin.co.nz
10 // NB: This is untested (probably buggy) code - take care if using it
11 // Nowhere near finished yet ...
15 using System.Collections;
17 namespace System.Net.Sockets
\r
20 public class Socket : IDisposable
\r
25 /// Blocks while waiting for readability, writeability or
\r
26 /// error conditions on a number of sockets
\r
28 /// <param name="read_list">A list of sockets to watch
\r
29 /// for readability</param>
\r
30 /// <param name="write_list">A list of sockets to watch
\r
31 /// for writeability</param>
\r
32 /// <param name="err_list">A list of sockets to watch
\r
33 /// for errors</param>
\r
34 /// <param name="time_us">Timeout, in microseconds</param>
35 public static void Select (
41 throw new NotImplementedException();
44 // public constructor:
47 /// Makes a new Socket
\r
49 /// <param name="family">Address family (e.g.
\r
50 /// AddressFamily.InterNetwork for IPv4)</param>
\r
51 /// <param name="type">Socket Type (e.g. SocketType.Stream
\r
52 /// for stream sockets)</param>
\r
53 /// <param name="proto">Protocol (e.g.
54 /// ProtocolType.Tcp for TCP)</param>
56 AddressFamily family,
\r
60 throw new NotImplementedException();
66 /// The address family (see contructor)
\r
68 public AddressFamily AddressFamily
\r
72 throw new NotImplementedException();
73 //return AddressFamily.InterNetwork;
78 /// How much data is waiting to be read (i.e. the amount
\r
79 /// of data in the in buffer)
\r
81 public int Available
\r
84 throw new NotImplementedException();
90 /// A flag to indicate whether the socket is a blocking
\r
91 /// socket or not. Returns true if blocking.
\r
93 /// A non-blocking socket (Blocking == false) will return
\r
94 /// control to the application immediately if any calls are
\r
95 /// made that may take a while to complete. Blocking
\r
96 /// sockets will block the app until whatever they are doing
\r
99 public bool Blocking
\r
102 throw new NotImplementedException();
109 /// A flag to say whether the socket is connected to something
\r
112 /// Returns true if connected.
\r
114 public bool Connected
\r
117 throw new NotImplementedException();
123 /// A handle to the socket (its file descriptor?)
\r
125 public IntPtr Handle
\r
128 throw new NotImplementedException();
129 //return new IntPtr(0);
134 /// The socket's local endpoint (where it's coming from)
\r
136 public EndPoint LocalEndPoint
\r
139 throw new NotImplementedException();
140 //return new IPEndPoint(0,0);
145 /// Protocol type (e.g. Tcp, Udp)
\r
147 public ProtocolType ProtocolType
\r
150 throw new NotImplementedException();
151 //return ProtocolType.Tcp;
156 /// The socket's remote endpoint (where it's connected to)
\r
158 public EndPoint RemoteEndPoint
\r
161 throw new NotImplementedException();
162 //return new IPEndPoint(0,0);
167 /// Socket type (e.g. datagram, stream)
\r
169 public SocketType SocketType
\r
172 throw new NotImplementedException();
173 //return SocketType.Stream;
180 /// Accepts a new connection
\r
182 /// <returns>A new socket to handle the connection</returns>
183 public Socket Accept ()
\r
185 throw new NotImplementedException();
186 //return new Socket(AddressFamily.InterNetwork,
187 // SocketType.Stream, ProtocolType.Tcp);
191 /// Accepts the connection in the background,
\r
192 /// calling the application back when finished.
\r
194 /// <param name="callback">A delegate to be called
\r
195 /// when the accept is finished</param>
\r
196 /// <param name="state">State information for this call</param>
\r
197 /// <returns></returns>
198 public IAsyncResult BeginAccept (
199 AsyncCallback callback,
202 throw new NotImplementedException();
206 /// Connects to a remote endpoint in the background,
\r
207 /// calling back when finished.
\r
209 /// <param name="remote_end_point">The endpoint to
\r
210 /// connect to</param>
\r
211 /// <param name="callback">Where to call when done</param>
\r
212 /// <param name="state">State information for this call</param>
\r
213 /// <returns></returns>
214 public IAsyncResult BeginConnect (
215 EndPoint remote_end_point,
216 AsyncCallback callback,
219 throw new NotImplementedException();
223 /// Receives data in the background, calling
\r
224 /// back when finished.
\r
226 /// <param name="buffer">A buffer to put the data into as it
\r
227 /// arrives</param>
\r
228 /// <param name="offset">Where to put the data (offset into
\r
229 /// the buffer)</param>
\r
230 /// <param name="size">Buffer size</param>
\r
231 /// <param name="socket_flags">Socket flags</param>
\r
232 /// <param name="callback">Where to call when the
\r
233 /// operation is finished</param>
\r
234 /// <param name="state">State info for this call</param>
\r
235 /// <returns></returns>
236 public IAsyncResult BeginReceive (
240 SocketFlags socket_flags,
241 AsyncCallback callback,
244 throw new NotImplementedException();
248 /// Receives data in the background from a specific
\r
249 /// point, calling back when finished.
\r
251 /// <param name="buffer">A buffer to put the data into as it
\r
252 /// arrives</param>
\r
253 /// <param name="offset">Where to put the data (offset into
\r
254 /// the buffer)</param>
\r
255 /// <param name="size">Buffer size</param>
\r
256 /// <param name="socket_flags">Socket flags</param>
\r
257 /// <param name="remote_end_point">Where to receive from</param>
\r
258 /// <param name="callback">Where to call when the
\r
259 /// operation is finished</param>
\r
260 /// <param name="state">State info for this call</param>
\r
261 /// <returns></returns>
262 public IAsyncResult BeginReceiveFrom (
266 SocketFlags socket_flags,
267 ref EndPoint remote_end_point,
268 AsyncCallback callback,
271 throw new NotImplementedException();
275 /// Starts sending data somewhere, in the background.
\r
277 /// <param name="buffer">Buffer containing the data to send</param>
\r
278 /// <param name="offset">Where in the buffer to start sending from</param>
\r
279 /// <param name="size">Buffer size</param>
\r
280 /// <param name="socket_flags">Socket flags</param>
\r
281 /// <param name="callback">Where to call back to when finished</param>
\r
282 /// <param name="state">State info for this call</param>
\r
283 /// <returns></returns>
284 public IAsyncResult BeginSend (
288 SocketFlags socket_flags,
289 AsyncCallback callback,
292 throw new NotImplementedException();
296 /// Starts sending data to a specific point, in the background
\r
298 /// <param name="buffer"></param>
\r
299 /// <param name="offset"></param>
\r
300 /// <param name="size"></param>
\r
301 /// <param name="socket_flags"></param>
\r
302 /// <param name="remote_end_point"></param>
\r
303 /// <param name="callback">Where to call back to when
\r
304 /// finished sending</param>
\r
305 /// <param name="state"></param>
\r
306 /// <returns></returns>
307 public IAsyncResult BeginSendTo (
311 SocketFlags socket_flags,
312 EndPoint remote_end_point,
313 AsyncCallback callback,
316 throw new NotImplementedException();
320 /// Binds the socket to a local endpoint
\r
322 /// <param name="local_end_point">What to
323 /// bind it to</param>
324 public void Bind (EndPoint local_end_point)
326 throw new NotImplementedException();
330 /// Closes the socket
\r
334 throw new NotImplementedException();
338 /// Connects to a remote system
\r
340 /// <param name="remote_end_point">Where to connect to</param>
341 public void Connect (EndPoint remote_end_point)
343 throw new NotImplementedException();
347 /// Completes an Accept() operation started
\r
348 /// with a BeginAccept() call
\r
350 /// <param name="result"></param>
\r
351 /// <returns></returns>
352 public Socket EndAccept (IAsyncResult result)
354 throw new NotImplementedException();
358 /// Completes an asynchronous Connect() operation
\r
359 /// started with a BeginConnect() call
\r
361 /// <param name="result"></param>
362 public void EndConnect (IAsyncResult result)
364 throw new NotImplementedException();
368 /// Completes an asynchronous Receive() operation
\r
369 /// started with a BeginReceive() call
\r
371 /// <param name="result"></param>
\r
372 /// <returns></returns>
373 public int EndReceive (IAsyncResult result)
375 throw new NotImplementedException();
379 /// Completes an asynchronous ReceiveFrom() operation
\r
380 /// started with a BeginReceiveFrom() call
\r
382 /// <param name="result"></param>
\r
383 /// <param name="end_point"></param>
\r
384 /// <returns></returns>
385 public int EndReceiveFrom (
387 ref EndPoint end_point)
389 throw new NotImplementedException();
393 /// Completes an asynchronous Send() operation
\r
394 /// started with a BeginSend() call
\r
396 /// <param name="result"></param>
\r
397 /// <returns></returns>
398 public int EndSend (IAsyncResult result)
400 throw new NotImplementedException();
404 /// Completes an asynchronous SendTo() operation
\r
405 /// started with a BeginSendTo() call
\r
407 /// <param name="result"></param>
\r
408 /// <returns></returns>
409 public int EndSendTo (IAsyncResult result)
411 throw new NotImplementedException();
415 /// Gets a socket option
\r
417 /// <param name="level"></param>
\r
418 /// <param name="name"></param>
\r
419 /// <returns></returns>
420 public object GetSocketOption (
421 SocketOptionLevel level,
422 SocketOptionName name)
424 throw new NotImplementedException();
428 /// Gets a socket option
\r
430 /// <param name="level"></param>
\r
431 /// <param name="name"></param>
\r
432 /// <param name="opt_value"></param>
433 public void GetSocketOption (
434 SocketOptionLevel level,
435 SocketOptionName name,
438 throw new NotImplementedException();
442 /// Gets a socket option
\r
444 /// <param name="level"></param>
\r
445 /// <param name="name"></param>
\r
446 /// <param name="length"></param>
\r
447 /// <returns></returns>
448 public byte[] GetSocketOption (
449 SocketOptionLevel level,
450 SocketOptionName name,
453 throw new NotImplementedException();
457 /// Does something to the socket, a la ioctl()
\r
459 /// <param name="ioctl_code">Code of the operation
\r
460 /// to perform on the socket</param>
\r
461 /// <param name="in_value">Data to pass to ioctl()</param>
\r
462 /// <param name="out_value">Data returned from ioctl()</param>
\r
463 /// <returns></returns>
464 public int IOControl (
469 throw new NotImplementedException();
473 /// Tells the socket to start listening
\r
475 /// <param name="backlog">Connection backlog - the number
476 /// of pending (not Accept()ed) connections that will be
477 /// allowed before new connections are automatically
479 public void Listen (int backlog)
481 throw new NotImplementedException();
485 /// Blocks the application until the socket is either
\r
486 /// readable, writeable or has an error condition
\r
488 /// <param name="time_us">How long to wait, in microseconds</param>
\r
489 /// <param name="mode">What to wait for (reading, writing, error)</param>
\r
490 /// <returns></returns>
491 public bool Poll (int time_us, SelectMode mode)
493 throw new NotImplementedException();
497 /// Receives data from the socket
\r
499 /// <param name="buf"></param>
\r
500 /// <returns></returns>
504 throw new NotImplementedException();
508 /// Receives data from the socket
\r
510 /// <param name="buf"></param>
\r
511 /// <param name="flags"></param>
\r
512 /// <returns></returns>
517 throw new NotImplementedException();
521 /// Receives data from the socket
\r
523 /// <param name="buf"></param>
\r
524 /// <param name="size"></param>
\r
525 /// <param name="flags"></param>
\r
526 /// <returns></returns>
532 throw new NotImplementedException();
536 /// Receives data from the socket
\r
538 /// <param name="buf"></param>
\r
539 /// <param name="offset"></param>
\r
540 /// <param name="size"></param>
\r
541 /// <param name="flags"></param>
\r
542 /// <returns></returns>
549 throw new NotImplementedException();
553 /// Receives data from a specific point,
\r
554 /// through the socket
\r
556 /// <param name="buf"></param>
\r
557 /// <param name="remote_end_point"></param>
\r
558 /// <returns></returns>
559 public int ReceiveFrom (
561 ref EndPoint remote_end_point)
563 throw new NotImplementedException();
567 /// Receives data from a specific point,
\r
568 /// through the socket
\r
570 /// <param name="buf"></param>
\r
571 /// <param name="flags"></param>
\r
572 /// <param name="remote_end_point"></param>
\r
573 /// <returns></returns>
574 public int ReceiveFrom (
577 ref EndPoint remote_end_point)
579 throw new NotImplementedException();
583 /// Receives data from a specific point,
\r
584 /// through the socket
\r
586 /// <param name="buf"></param>
\r
587 /// <param name="size"></param>
\r
588 /// <param name="flags"></param>
\r
589 /// <param name="remote_end_point"></param>
\r
590 /// <returns></returns>
591 public int ReceiveFrom (
595 ref EndPoint remote_end_point)
597 throw new NotImplementedException();
601 /// Receives data from a specific point,
\r
602 /// through the socket
\r
604 /// <param name="buf"></param>
\r
605 /// <param name="offset"></param>
\r
606 /// <param name="size"></param>
\r
607 /// <param name="flags"></param>
\r
608 /// <param name="remote_end_point"></param>
\r
609 /// <returns></returns>
610 public int ReceiveFrom (
615 ref EndPoint remote_end_point)
617 throw new NotImplementedException();
622 /// Sends data through the socket
\r
624 /// <param name="buffer"></param>
\r
625 /// <returns></returns>
629 throw new NotImplementedException();
633 /// Sends data through the socket
\r
635 /// <param name="buffer"></param>
\r
636 /// <param name="flags"></param>
\r
637 /// <returns></returns>
642 throw new NotImplementedException();
646 /// Sends data through the socket
\r
648 /// <param name="buffer"></param>
\r
649 /// <param name="size"></param>
\r
650 /// <param name="flags"></param>
\r
651 /// <returns></returns>
657 throw new NotImplementedException();
661 /// Sends data through the socket
\r
663 /// <param name="buffer"></param>
\r
664 /// <param name="offset"></param>
\r
665 /// <param name="size"></param>
\r
666 /// <param name="flags"></param>
\r
667 /// <returns></returns>
674 throw new NotImplementedException();
678 /// Sends data to a specific point,
\r
679 /// through the socket
\r
681 /// <param name="buffer"></param>
\r
682 /// <param name="remote_end_point"></param>
\r
683 /// <returns></returns>
686 EndPoint remote_end_point)
688 throw new NotImplementedException();
692 /// Sends data to a specific point,
\r
693 /// through the socket
\r
695 /// <param name="buffer"></param>
\r
696 /// <param name="flags"></param>
\r
697 /// <param name="remote_end_point"></param>
\r
698 /// <returns></returns>
702 EndPoint remote_end_point)
704 throw new NotImplementedException();
708 /// Sends data to a specific point,
\r
709 /// through the socket
\r
711 /// <param name="buffer"></param>
\r
712 /// <param name="size"></param>
\r
713 /// <param name="flags"></param>
\r
714 /// <param name="remote_end_point"></param>
\r
715 /// <returns></returns>
720 EndPoint remote_end_point)
722 throw new NotImplementedException();
726 /// Sends data to a specific point,
\r
727 /// through the socket
\r
729 /// <param name="buffer"></param>
\r
730 /// <param name="offset"></param>
\r
731 /// <param name="size"></param>
\r
732 /// <param name="flags"></param>
\r
733 /// <param name="remote_end_point"></param>
\r
734 /// <returns></returns>
740 EndPoint remote_end_point)
742 throw new NotImplementedException();
746 /// Sets a socket option (like setsockopt())
\r
748 /// <param name="level"></param>
\r
749 /// <param name="name"></param>
\r
750 /// <param name="opt_value"></param>
751 public void SetSocketOption (
752 SocketOptionLevel level,
753 SocketOptionName name,
756 throw new NotImplementedException();
760 /// Sets a socket option (like setsockopt())
\r
762 /// <param name="level"></param>
\r
763 /// <param name="name"></param>
\r
764 /// <param name="opt_value"></param>
765 public void SetSocketOption (
766 SocketOptionLevel level,
767 SocketOptionName name,
770 throw new NotImplementedException();
774 /// Sets a socket option (like setsockopt())
\r
776 /// <param name="level"></param>
\r
777 /// <param name="name"></param>
\r
778 /// <param name="opt_value"></param>
779 public void SetSocketOption (
780 SocketOptionLevel level,
781 SocketOptionName name,
784 throw new NotImplementedException();
788 /// Stops anyone from being able to read or write to the socket
\r
790 /// <param name="how">What people aren't allowed to do any
791 /// more (you can disable just reading or just writing, or both)</param>
792 public void Shutdown (SocketShutdown how)
794 throw new NotImplementedException();
798 /// A stringified representation of the socket
\r
800 /// <returns></returns>
801 public override string ToString ()
803 throw new NotImplementedException();
809 // protected methods:
812 /// Disposes of all unmanaged resources, and
\r
813 /// managed resources too if requested
\r
815 /// <param name="disposing">Set this to true
816 /// to dispose of managed resources</param>
817 protected virtual void Dispose (bool disposing)
819 // file descriptor / socket
820 // other things to dispose of?
824 throw new NotImplementedException();
828 /// Disposes of everything (managed and
\r
829 /// unmanaged resources)
\r
831 public void Dispose ()
837 /// Destructor - disposes of unmanaged resources
\r
842 throw new NotImplementedException();