• C

how to compile winsock program ?

I'm from a UNIX environment programmer and i faced a problem of compiling a socket program (it work on UNIX).
Currently i'm using borland C++4.5 and i'm trying to write a windows base socket program.

just some need info, is that enough just only include thw winsock.h header file ? or what else do i need ? any .lib file or .dll file ? if yes, how do i make a linking of it ?

error occur when i try to link the program, it said undefine symbol SOCKET in mysock.cpp

how should i solve that ?
tsungAsked:
Who is Participating?
 
jhjeonConnect With a Mentor Commented:
do you use 16bit API...?
Borland 4.x Linking is Differ

http://www.goodnet.com/~esnible/winsock.html

"Note that it doesn't matter whose Winsock you are using, the same .LIB file works with all 16 bit programs, and you don't need a .LIB for 32 bit programs. Also note that these versions are a bit more recent than the version in the WINSOCK.HLP normally shipped with BC++.
If you are using Borland C++ 4.0 you got a free WINSOCK.HLP and WINSOCK.H, but no WINSOCK.DLL, so your programs can't link. You can use the provided IMPLIB to make a WINSOCK.LIB from your WINSOCK.DLL."


0
 
_ZaphodCommented:
You need to link wsock32.lib or winsock.lib, depending on your compiler.
0
 
tsungAuthor Commented:
How should i make the linkage for the winsock.lib to my program if i'm using the borland c++ 4.5 compiler ?
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
kellyjjCommented:
This is proboly a dumb question but you do have SOCKET defined somewhere??  I use borland 4.5  I will see if I can't figure out how to do the linking.
0
 
tsungAuthor Commented:
I checked the winsock.h header file and there is a line of code ---> typedef unsigned int SOCKET
been defined in the header file.

is there any others possibility which cause this problem ?
0
 
jtwine100697Commented:
  Search through your includes and code for any "strange" uses of "SOCKET".  It is just supposed to be a variable (uint).  But since you are getting linker errors, the compiler thinks that SOCKET is a function or some other block of code.

-=- James.

0
 
_ZaphodCommented:
Linking winsock.lib or wsock32.lib didn't help? All socket symbols are defined there.
0
 
tsungAuthor Commented:
I have try the same program and same libraries and it work on MSVC 5.0. But how come Borland C can't do it ?
0
 
_ZaphodCommented:
You never know the mysterious ways of compilers/linkers - what they include by default, what they include when they see something's missing, et cetera
0
 
SlartiCommented:
This sounds like a serious question. Why don't you increase the points to 50 (at least)?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.