|
Im having trouble using sockets with MFC
i have downloaded many examples
but everytime i try to compile my own they wont work
i need a simple tutorial to get me started with them
i would also like to figure out how to use sockets without MFC
|
|
|
|
|
Beej's Guide to Network Programming[^]... the best tutorial i've ever read about sockets. there, search for the PDF.
in fact, it's not exactly about windows sockets (it is even linux oriented), but this recalls the Berkeley sockets, which is quite the same whatever the plateform.
For windows, you just have to #include <winsock.h> , and to write some lines with WSADATA :
<font style="color:blue;">#include</font> <winsock.h>
<font style="color:green;">
{
WSADATA wsaData; <font style="color:green;">
<font style="color:green;">
<font style="color:blue;">if</font> (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
fprintf(stderr, <font style="color:purple;">WSAStartup failed.\n"</font>);
exit(1);
}
<font style="color:green;">//...</font>
}
But don't worry, that is explain it the 1.5. Note for Windows Programmers
have a look, that's interresting !
Best regards
TOXCCT >>> GEII power
|
|
|
|
|
Here are a couple of nice non-MFC tutorials:
You'd need to provide more information about the compilation errors you're getting if you'd like help!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
socketsdlg.h(34) : error C2146: syntax error : missing ';' before identifier 'cmSocket'
socketsdlg.h(34) : error C2501: 'CMySocket' : missing storage-class or type specifiers
socketsdlg.h(34) : error C2501: 'cmSocket' : missing storage-class or type specifiers
SocketsDlg.cpp
socketsdlg.h(34) : error C2146: syntax error : missing ';' before identifier 'cmSocket'
socketsdlg.h(34) : error C2501: 'CMySocket' : missing storage-class or type specifiers
socketsdlg.h(34) : error C2501: 'cmSocket' : missing storage-class or type specifiers
SocketsDlg.cpp(176) : error C2065: 'cmSocket' : undeclared identifier
SocketsDlg.cpp(176) : error C2228: left of '.Create' must have class/struct/union type
SocketsDlg.cpp(177) : error C2228: left of '.Connect' must have class/struct/union type
you can view the source of the files here
http://members.lycos.co.uk/archer282/Sockets/
|
|
|
|
|
You need to #include MySocket.h .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
thank you.
i never even thought to make sure thet it was inlcluding the header.
i just assumed since it was an MFC project that it would have been done automatically.
|
|
|
|
|
You all must be familiar with the send to menu in win, like when you right-click a file you get send to and then some program can I ad my program here(programaticly that is). Or even better can you ad it to the right-click menu instead, like when you right click it it will say edit with myapp next to edit with visual studio.?
|
|
|
|
|
|
I guess it's as simple as adding *.lnk file to some directory in windows root (at least it worked with simple directory links). Too bad I forgot the exact path, but you can easily find it anyway, I'm sure.
|
|
|
|
|
Someone told me that you cant have VC++ 6.0 and VC++ .net on the same computer because they will mess each other up. Is this true? If so, is there anyway around it?
Thanks a lot
David
|
|
|
|
|
Bullsh_t!
There are both VC++ 6 and VC++.NET on this computer which I am using. No problem with them at all.
Maxwell Chen
|
|
|
|
|
i confirm max'l chen's post... i both use VC++ 7 and .NET and i've got no pb... (i also have a piece of the VC++ 5 !!! )... no problem so
TOXCCT >>> GEII power
|
|
|
|
|
The trick is to install VC++ 6.0 first and if you uninstall it, you need to run a repair on the VC++.NET install to restore the file associations.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I have VC++ 1.52c (for DOS based apps), Visual Studio 6.0 and Visual Studio .NET 2003 installed on each of my machines (home using XP Pro, work using W2K and a laptop using XP Pro). No problems at all...
Steve
|
|
|
|
|
Steve Mayfield wrote:
have VC++ 1.52c
How did you install VC++ 1.52c on WinXP? I am curious!
My VC++ 1.5x only allows me to install on Win98...
Maxwell Chen
|
|
|
|
|
All I had to do was put in the CD and run the setup program. I just tried the V1.52 setup program again and it starts up OK. You probably need to install V1.52, then VS6.0 and finally VS .NET so the various settings are done in the correct order. There is a batch file that V1.52 Setup creates that has the various Environment Variables initializations - I took them and merged them into the Environment Variables under Control Panel / System / Advanced / User Variables.
Steve
|
|
|
|
|
Steve Mayfield wrote:
You probably need to install V1.52, then VS6.0 and finally VS .NET
Well, I haven't have a clean WinXP system to try this way. Next time I'll have a try when I get a clean system.
When I launch the VC++1.51 setup, it pops up a message box for only Win95/98 supported.
Maxwell Chen
|
|
|
|
|
Are 6 and .net on different hard drive partitions? Just dont want to mess things up.
Thanks a lot for the replies!!
David
|
|
|
|
|
They don't need to be. I have VC6, VS.NET 2002, and VS.NET 2003 installed together on several machines. By default, they install to separate directories.
Software Zen: delete this;
|
|
|
|
|
something wrong with my func(I marked probkem arrea) :
char buf[MAXCODE];
ClearString(buf);
//Send "BEGINRECV"
if(!send(Client,"BRCV",MAXCODE,0))
return ERR;
//Request query
if(!recv(Client,buf,MAXCODE,0))
return ERR;
if (strnicmp(buf,"SUCC",4) != 0)
return NOREQUEST;
ClearString(buf);
//Send "SIZE"
if (!send(Client,"SIZE",MAXCODE,0))
return ERR;
//Request query
if(!recv(Client,buf,MAXCODE,0))
return ERR;
if (strnicmp(buf,"SUCC",4) != 0)
return NOREQUEST;
ClearString(buf);
char *recvSize;
recvSize = new char[MAXMESS];
ClearString(recvSize);
//Recieve SIZE
if(!recv(Client,recvSize,4,0))
return ERR;
if(!send(Client,"SUCC",MAXCODE,0))
return NOREQUEST;
int size = StringToInt(recvSize);
delete [] recvSize;
char *data;
data = new char[size];
ClearString(data);
// Here recv recieves "BRCV" whatever server sends. If server doesnot send anything it anyway recieves "BRCV"
// It always recieves "BRCV"
if(!recv(Client,data,size,0))
return ERR;
if(!send(Client,"SUCC",MAXCODE,0))
return NOREQUEST;
fData.Empty();
fData = data;
fData.Insert(size, '\0');
delete [] data;
//Send "ENDRECV"
if(!send(Client,"ERCV",MAXCODE,0))
return ERR;
//Request query
if(!recv(Client,buf,MAXCODE,0))
return ERR;
if (strnicmp(buf,"SUCC",4) != 0)
return NOREQUEST;
ClearString(buf);
|
|
|
|
|
have you ever tried to send a string that was containing white spaces...? the string is not sent entierly. if you do this :
strcpy(strBuf, <font style="color:purple;">"hello world!"</font>);
send(sockfd, strBuf, strlen(strBuf), 0);
you will have "hello" received, then at the next recv() call on the peer, "world!" will be get.
it looks the same thing here. are you sure you don't send a white spaced string ?
TOXCCT >>> GEII power
|
|
|
|
|
Using MFC I needed to create 10 Excel sheets within 1 workBook ! I am really having trouble doing this .
|
|
|
|
|
Please explain your "trouble" in more detail. You'll receive more help this way.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Using MFC I needed to create 10 sheets ! I am really having trouble doing this .
|
|
|
|
|
Hai
How to implement autoshape in Microsoft dhtmled control. Pls give the suggesition
|
|
|
|