[Winpcap-users] Problems with Tutorial no.6 (UDP dump)

Vasily Borovyak vbor at isd.dp.ua
Wed May 3 08:22:12 GMT 2006

Hello Tomek.
I think you forgot to link WinSock2 library Ws2_32.lib.
I'll copypaste the MSDN page:


The *htons* function converts a *u_short* from host to TCP/IP network 
byte order (which is big-endian).

*u_short* *htons(*
  *u_short* /hostshort/*


    [in] 16-bit number in host byte order. 

        Return Values

The *htons* function returns the value in TCP/IP network byte order.


The *htons* function takes a 16-bit number in host byte order and 
returns a 16-bit number in network byte order used in TCP/IP networks.


*Client: *Requires Windows XP, Windows 2000 Professional, Windows NT 
Workstation, Windows Me, Windows 98, or Windows 95.
*Server: *Requires Windows Server 2003, Windows 2000 Server, or Windows 
NT Server.
*Header: *Declared in Winsock2.h.
*Library: *Use Ws2_32.lib.

        See Also

Winsock Reference <winsock_reference.htm>, Winsock Functions 
<winsock_functions.htm>, *htonl* <htonl_2.htm>, *ntohl* <ntohl_2.htm>, 
*ntohs* <ntohs_2.htm>, *WSAHtonl* <wsahtonl_2.htm>, *WSAHtons* 
<wsahtons_2.htm>, *WSANtohl* <wsantohl_2.htm>, *WSANtohs* <wsantohs_2.htm>

Tomek Czerwinski wrote:
> Hi!
> Im just starting with WinPcap, so sorry, if it will be a nooby
> question.
> I use Microsoft Visual Studio 6.0 on WinXP. Today I tryied to run all
> tutorials from the WinPcap site to see if anything goes wrong. Whole
> code from lessons 1-5 works (compile+link+runs) just fine, but when
> trying to link tutorial 6 i get such error:
> Linking...
> source.obj : error LNK2001: unresolved external symbol __imp__ntohs at 4
> Debug/Lekcja6.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
> Lekcja6.exe - 2 error(s), 0 warning(s)
> On lines 193 and 194 i see that linker is haveing a problem with
> function ntosh() and I dont have any idea why. I would be really
> gratefull for any help!
> And sorry for my english:> I havent slept for 3 days:/
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users

Best regards. Vasily Borovyak <vbor at isd.dp.ua>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060503/91c9ac12/attachment.html

More information about the Winpcap-users mailing list