Bill

Bill

  • NA
  • 16
  • 0

Subclassing Socket

Mar 27 2008 2:47 PM
I'm trying to use sockets to create a proxy connection to a server. The whole thing worked perfectly until I tried to add a custom class to deal with the proxy (authentication etc). I have two sockets, ListeningSocket and DataSocket.

The problem is that I can't see to get listeningsocket to accept datasocket as a ProxySocket, only as a standard socket.

ProxySocket extends Socket, but I can't get it to work.

Here's the code:
In the head of the class
    private ProxySocket dataSocket = null;
    private Socket listeningSocket = null; // used to accept active connections


The in the method to accept the connection.

        listeningSocket = new Socket(AddressFamily.InterNetwork,   SocketType.Stream, ProtocolType.Tcp);
        listeningSocket.Bind(localEnd);
        listeningSocket.Listen(1);
        Socket dataSockTemp = listeningSocket.Accept(); // at this point, dataSockTemp is a connected Socket (shown via a breakboint)
        dataSocket = dataSockTemp as ProxySocket;
        listeningSocket.Close();


I'd really appreciate any help.