| | |
plzzz help! i did the work need
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2003
Posts: 58
Reputation:
Solved Threads: 0
well i have been working on a server client program and i got the server working but the client isnt.
Program Flow of a simple TCP client:
1)Initialize WinSock library using WSAStartup()
2)Create a IPPROTO_TCP SOCKET using socket()
3)Connect to the server using the socket we created, using connect()
4)Close the socket connection using closesocket()
5)De-Initialize WinSock using WSACleanup()
void main()
{
// Initialize WinSock
int wsaret=WSAStartup(0x101,&wsaData);
if(wsaret)
return;
//Create the SOCKET
SOCKET conn;
conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(conn==INVALID_SOCKET)
return;
//connecting to server
//problem here
connect(conn,(struct sockaddr*)&127.0.0.1,sizeof(127.0.0.1))
//clean up mess
closesocket(conn);
WSACleanup();
}
thats the code.
these are the erros i get.
error C2065: 'wsaData' : undeclared identifier
error C2101: '&' on constant
error C2440: 'type cast' : cannot convert from 'const double' to 'struct sockaddr *'
There is no context in which this conversion is possible
error C2143: syntax error : missing ')' before 'constant'
error C2660: 'connect' : function does not take 2 parameters
error C2059: syntax error : ')'
Error executing cl.exe.
client.exe - 6 error(s), 0 warning(s)
any help will be greatly apprecaited. thx
Program Flow of a simple TCP client:
1)Initialize WinSock library using WSAStartup()
2)Create a IPPROTO_TCP SOCKET using socket()
3)Connect to the server using the socket we created, using connect()
4)Close the socket connection using closesocket()
5)De-Initialize WinSock using WSACleanup()
void main()
{
// Initialize WinSock
int wsaret=WSAStartup(0x101,&wsaData);
if(wsaret)
return;
//Create the SOCKET
SOCKET conn;
conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(conn==INVALID_SOCKET)
return;
//connecting to server
//problem here
connect(conn,(struct sockaddr*)&127.0.0.1,sizeof(127.0.0.1))
//clean up mess
closesocket(conn);
WSACleanup();
}
thats the code.
these are the erros i get.
error C2065: 'wsaData' : undeclared identifier
error C2101: '&' on constant
error C2440: 'type cast' : cannot convert from 'const double' to 'struct sockaddr *'
There is no context in which this conversion is possible
error C2143: syntax error : missing ')' before 'constant'
error C2660: 'connect' : function does not take 2 parameters
error C2059: syntax error : ')'
Error executing cl.exe.
client.exe - 6 error(s), 0 warning(s)
any help will be greatly apprecaited. thx
Last edited by fakespike; Sep 27th, 2003 at 5:28 pm.
Indeed, this is a duplicate post. Please direct all future responses to http://www.daniweb.com/forums/thread1190.html (this way, all responses to the thread are together)
Thanks!
Thanks!
![]() |
Similar Threads
- Need 2 techies for tech-support, work from home (Tech / IT Consultant Job Offers)
- Requesting shadowing work at home job (Software Development Job Offers)
Other Threads in the C Forum
- Previous Thread: read ip on xp
- Next Thread: TreeListView problem
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o ide inches include infiniteloop initialization input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft multi mysql oddnumber open opendocumentformat openwebfoundation overwrite pdf pointer pointers posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation testing threads unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






