TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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.
Reply
Answers (
0
)
Generating a Random Number
NP91 Clone() method