Results 1 to 4 of 4

Thread: Why this socket code doesnt work?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Why this socket code doesnt work?

    Code:
    TcpClient client = new TcpClient();
    client.Connect("127.0.0.1", 21);
    client.GetStream().BeginRead(buffer, 0, buffer.Length, new AsyncCallback(ReadCallBack), null);
    Code:
    static void ReadCallBack(IAsyncResult callback) {
    int res = stream.EndRead(callback);
    if (res == 0) {
    return;
    }
    
    string str = Encoding.Default.GetString(buffer);
    Console.WriteLine(str);
    I don't understand why it doesnt work. It should connect to my ftp(and it does as i can see it in my ftp server) and receive a "Bullet ftp serv" message but it doesn't!
    The problem seems to be that the ReadCallBack method doesnt even get fired..but why?!
    \m/\m/

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    static void ReadCallBack(IAsyncResult callback)


    You didn't supply an argument to that function...

    VB Code:
    1. client.GetStream().BeginRead(buffer, 0, buffer.Length, new AsyncCallback(ReadCallBack([b]something_here[/b])), null);


    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    No. Its a function pointer, its the BeginRead() function's work to fill it with the needed parameter not to me.

    The problem shouldn't be there (as i am not even allowed to put an arg there)
    \m/\m/

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    bump
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width