TCPClient + GetStream();


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: TCPClient + GetStream();

  1. #1
    TBusot Guest

    TCPClient + GetStream();


    I'm trying to write a small ap in C# that queries a whois server and returns
    the record. The MSDN docs show something like this as how to pass the domain
    to the server:

    string sDName = "busot.com";
    TCPClient oClient = new TCPClient("whois.opensrs.net",43);
    Stream oStream = oClient.GetStream();
    oStream.Write(sDName);

    But when I try this, it tells me "no overload for method 'Write' takes '1'
    arguments

    It seems that it is looking for a byte type array, an offset int and count
    int, but the documentation does not show this.

    Any clues?



  2. #2
    GJ Guest

    Re: TCPClient + GetStream();


    I always found these implementations to be quirky and never to my liking,
    so I always stick with the basics and imlement my own functionality... With
    C++, I passed aside CSockets and CASyncSockets and just used the Win32API.

    In C#, I passed aside the TCPClient and UDPClient, and implemented my own
    just using System.Net.Socket. You'll actually find life to be much easier,
    if you implement your own, because you have total control. I've implemented
    just about everything from RTSP to a web server to things I can't mention
    because of pesky NDAs

    Anyways FWIW, all the stuff I've used and read also takes Byte Arrays.

    If you wanted help implmenting this with Generic Sockets, just let me know...

    As for write, I'm not sure about TCPClient.Write, but for Socket.Write it
    takes a ByteArray, so I'm guessing so does TCPClient.Write

    In which case, do this:

    UTF8Encoding UTF8 = new UTF8Encoding();
    Char[] CharArray = sdName.ToCharArray();
    Byte[] ByteArray = new Byte[UTF8.GetByteCount(CharArray)];

    UTF8.GetBytes(CharArray,0,CharArray.Length,ByteArray,0);
    oStream.Write(ByteArray,0,ByteArray.Length);




    "TBusot" <tbusot@hotmail.com> wrote:
    >
    >I'm trying to write a small ap in C# that queries a whois server and returns
    >the record. The MSDN docs show something like this as how to pass the domain
    >to the server:
    >
    > string sDName = "busot.com";
    > TCPClient oClient = new TCPClient("whois.opensrs.net",43);
    > Stream oStream = oClient.GetStream();
    > oStream.Write(sDName);
    >
    >But when I try this, it tells me "no overload for method 'Write' takes '1'
    >arguments
    >
    >It seems that it is looking for a byte type array, an offset int and count
    >int, but the documentation does not show this.
    >
    >Any clues?
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center