P/Invoke winsock.dll

G

Guest

Hello

I'm trying to call the winsock api in C# CF
Is it possible to call the inet_addr(const char* server) from .NET CF application
I got System.NotSupportedException when I tried below codes

[DllImport("winsock.dll", EntryPoint="inet_addr", CharSet=CharSet.Unicode, SetLastError=true)
public static extern ulong inet_addr(char[] cp); o
public static extern ulong inet_addr(byte[] cp)

Any ideas or suggestions are welcome

Thanks
Re
 
A

Alex Feinman [MVP]

Wouldn't it be nice if people read FAQ?....

[DllImport("winsock.dll", EntryPoint="inet_addr", CharSet=CharSet.Unicode,
SetLastError=true)]
public static extern uint inet_addr(byte[] cp);

call as:

inet_addr(Encoding.ASCII.GetBytes("192.168.0.1"))

You can get the same results without PInvoke using
IPAddress.Parse("192.168.0.1").Address
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top