-
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?
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks