Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
GeneralRe: System tray refresh? Pin
Luc Pattyn31-Jul-09 9:10
sitebuilderLuc Pattyn31-Jul-09 9:10 
GeneralRe: System tray refresh? Pin
mark_me31-Jul-09 10:01
mark_me31-Jul-09 10:01 
GeneralRe: System tray refresh? Pin
Luc Pattyn31-Jul-09 10:16
sitebuilderLuc Pattyn31-Jul-09 10:16 
Questioncomputer graphics Pin
neelam99999999931-Jul-09 6:28
neelam99999999931-Jul-09 6:28 
AnswerRe: computer graphics Pin
Xmen Real 31-Jul-09 6:59
professional Xmen Real 31-Jul-09 6:59 
AnswerRe: computer graphics Pin
Henry Minute31-Jul-09 9:41
Henry Minute31-Jul-09 9:41 
AnswerRe: computer graphics Pin
Luc Pattyn31-Jul-09 18:43
sitebuilderLuc Pattyn31-Jul-09 18:43 
QuestionSocket Authentication in C# Pin
joana.simoes31-Jul-09 5:35
joana.simoes31-Jul-09 5:35 
Hi,

I created a proxy that listens on a port for a requests, and then redirects them to a server. For that I created a listening socket, and a client socket that streams the data.
The problem is that the server is using Authentication (for instance NTLM, or digest) and I need to authenticate the request.
I know that I can do it in a webrequest, using CredentialCache object; something like this:

CredentialCache credCache = new CredentialCache();
 if ((auth & (uint)EAuthenticationFlags.eWindows) != 0) {
     credCache.Add(URL, "Negotiate", (NetworkCredential) CredentialCache.DefaultCredentials);}

 webRequest.Credentials = credCache;


However, I am unsure how to do it if all I have in my hand is a socket and a stream of data. Something like this:


ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), ClientSocket);
DestinationSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, new AsyncCallback(this.OnRemoteReceive), DestinationSocket);


And the code for the callbacks [b]OnClientReceive[/b] and [b]OnRemoteReceive[/b]:

protected void OnClientReceive(IAsyncResult ar)
{
    try
    {
        int Ret = ClientSocket.EndReceive(ar);
        if (Ret <= 0)
        {
            Dispose();
            return;
        }
        DestinationSocket.BeginSend(Buffer, 0, Ret, SocketFlags.None, new AsyncCallback(this.OnRemoteSent), DestinationSocket);
    }
    catch
    {
        Dispose();
    }
}

protected void OnRemoteReceive(IAsyncResult ar)
{
    try
    {
        int Ret = DestinationSocket.EndReceive(ar);
        if (Ret <= 0)
        {
            Dispose();
            return;
        }
        ClientSocket.BeginSend(RemoteBuffer, 0, Ret, SocketFlags.None, new AsyncCallback(this.OnClientSent), ClientSocket);
    }
    catch
    {
        Dispose();
    }
}




Does anybody has any suggestions of where the authentication should take place and how? Can I append a credentials object somehow to the socket o or to the stream of data? or worst case scenario, can I just append the correct http headers?
Thanks in advance for your time,
cheers,
Jo
Questionhow to convert list to dictionary Pin
hotthoughtguy31-Jul-09 3:55
hotthoughtguy31-Jul-09 3:55 
AnswerRe: how to convert list to dictionary Pin
Henry Minute31-Jul-09 4:08
Henry Minute31-Jul-09 4:08 
GeneralRe: how to convert list to dictionary Pin
hotthoughtguy31-Jul-09 4:12
hotthoughtguy31-Jul-09 4:12 
GeneralRe: how to convert list to dictionary Pin
hotthoughtguy31-Jul-09 4:14
hotthoughtguy31-Jul-09 4:14 
GeneralRe: how to convert list to dictionary [modified] Pin
Henry Minute31-Jul-09 5:06
Henry Minute31-Jul-09 5:06 
GeneralRe: how to convert list to dictionary Pin
Luc Pattyn31-Jul-09 9:18
sitebuilderLuc Pattyn31-Jul-09 9:18 
GeneralRe: how to convert list to dictionary Pin
Henry Minute31-Jul-09 9:22
Henry Minute31-Jul-09 9:22 
GeneralRe: how to convert list to dictionary Pin
Luc Pattyn31-Jul-09 10:01
sitebuilderLuc Pattyn31-Jul-09 10:01 
GeneralRe: how to convert list to dictionary Pin
Henry Minute31-Jul-09 10:11
Henry Minute31-Jul-09 10:11 
GeneralRe: how to convert list to dictionary Pin
Luc Pattyn31-Jul-09 10:29
sitebuilderLuc Pattyn31-Jul-09 10:29 
GeneralRe: how to convert list to dictionary Pin
Dan Neely31-Jul-09 9:26
Dan Neely31-Jul-09 9:26 
AnswerRe: how to convert list to dictionary Pin
Super Lloyd31-Jul-09 4:18
Super Lloyd31-Jul-09 4:18 
GeneralRe: how to convert list to dictionary Pin
hotthoughtguy31-Jul-09 4:28
hotthoughtguy31-Jul-09 4:28 
AnswerRe: how to convert list to dictionary Pin
0x3c031-Jul-09 4:38
0x3c031-Jul-09 4:38 
GeneralRe: how to convert list to dictionary Pin
hotthoughtguy31-Jul-09 4:44
hotthoughtguy31-Jul-09 4:44 
AnswerRe: how to convert list to dictionary Pin
Dave Kreskowiak31-Jul-09 5:05
mveDave Kreskowiak31-Jul-09 5:05 
QuestionProgrammatically updating application properties or help creating my own xml file please. Pin
JollyMansArt31-Jul-09 2:51
JollyMansArt31-Jul-09 2:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.