Joined: 24 Mar 2004 Posts: 491
Location: Dhaka, Bangladesh
Post subject:
The reason you're getting this is you didn't add correct lib for API snprintf, bind and others. Those are part of POSIX C and part of following header.
You've to find similier API from winsock.h to work with it.
-DK. _________________ ...we too are stardust...
Tue Jun 08, 04 12:50 am
Tousif Beginner User
Joined: 25 May 2004 Posts: 20
Location: Nashville, Tennessee, USA
Post subject:
DK:
But do you think if this was due to those function not being in the API, he would have been able to compile this program to begin with? I didn't have time to check others but I've checked one of them and "bind" exist under winsock.h. He shouldn't have gotten that error at least.
To me, it seems more like a linking issue than anything else. Are you sure quantum, you have all the linking done correctly?
Tousif
Tue Jun 08, 04 3:26 am
quantum Site Admin
Joined: 07 Mar 2004 Posts: 1048
Location: Dhaka, Bangladesh
Post subject:
The code compiled alright, without any error.
I am more or less sure the linking is okay. Could you please check the code your machine? _________________
Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Tue Jun 08, 04 6:40 am
dinangkur Super Moderator
Joined: 24 Mar 2004 Posts: 491
Location: Dhaka, Bangladesh
Post subject:
Sorry for the mistake Mr. Tousif. I never did any works with winsock, so don't have any deep knowledge about it. It seems to me it's linking error. When it's try to create .exe file, it fails to link with the libs.
under windows, snprinf is defined as _snprintf. So that was one reason and as a general practice, I've added the #def. Also you don't have tTime declared but have used it in ctime, so I've used currentTime. Change it to your linking.
You should not treat a socket just like a normal file and thus shouldn't be applying write() and close() on a socket. Instead use send() and closesocket(). You might wanna use sendto() instead of send() depending on your need but the point is look it up in the winsock API and use the appropriate function.
I hope this will run on your machine.
Tousif
Wed Jun 09, 04 2:56 am
Tousif Beginner User
Joined: 25 May 2004 Posts: 20
Location: Nashville, Tennessee, USA
Post subject:
One more thing, I had to manually add the linking library wsock32.lib . To do this, in Visual C++, go to project->settings, click on the link tab and then under object/library modules, add that library name at the end. remember to keep each library module seperate:)
If you are using 16 bit application, add winsock.h instead.
Tousif
Wed Jun 09, 04 3:06 am
quantum Site Admin
Joined: 07 Mar 2004 Posts: 1048
Location: Dhaka, Bangladesh
Now bear with me. I am NOT a VC++ guy. So treat me as a novice.
Quantum
Mon Jun 14, 04 12:53 am
Tousif Beginner User
Joined: 25 May 2004 Posts: 20
Location: Nashville, Tennessee, USA
Post subject:
Hi,
Well..first of all I am not a fan of $M :) So, if there are alternatives I would not program in VC++.I use it only when I must and not an expert in it.
Anyways..as it looked to me it doesn't know "winmain", so basically you are running a program that takes the windows application main program "winmain" as default instead normal "main".
I was able to produce your error...I guess when you've started this in File->New->Project, you've selected it as Win32 Application or something that requires "winmain".
What I did was just a simple Win32 Console application..ones that take "main" as the default starting point.
This should solve your problem.
Tousif
Mon Jun 14, 04 1:24 am
dinangkur Super Moderator
Joined: 24 Mar 2004 Posts: 491
Location: Dhaka, Bangladesh
Post subject:
Yes Mr. Tousif you're right.
-DK. _________________ ...we too are stardust...
Mon Jun 14, 04 1:51 am
quantum Site Admin
Joined: 07 Mar 2004 Posts: 1048
Location: Dhaka, Bangladesh
Post subject:
Very nice...that was it.
The main problem that needed to be solved here was adding the wsock32.lib in the link library as you said. And turning it into console mode did the job. Thanks.
Yeah, I agree with your opinion about M$ VC++. I am turning to borland from now on for windows. _________________
Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.