"implements the msdn"? MSDN is not a library or a verison of libc++, it's just a website with lots of information. it stands for microsoft developer network. VC7 has an implementaiton of Win32API and Winsock, which implements this behavior.
"implements the msdn"? MSDN is not a library or a verison of libc++, it's just a website with lots of information. it stands for microsoft developer network. VC7 has an implementaiton of Win32API and Winsock, which implements this behavior.
but if the msdn says it's int, then VC7 implemented it as int.
ok, forget about msdn...
Borland C++ 5.5 implemintation:VC 6 implemintation:Code:SOCKET PASCAL FAR accept ( IN SOCKET s, OUT struct sockaddr FAR *addr, IN OUT int FAR *addrlen);and even Bloodshed DevC++:Code:SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen);Code:SOCKET PASCAL accept(SOCKET,struct sockaddr*,int*);
Last edited by Devil Panther; 08-13-2005 at 01:20 PM.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Because MSDN documents what Vc7 does, not the other way round. But this is certinaly pedantic and not worth continuing.
new question
i tried to consolidate my server and client in one program.
i created a program using both beej and madwizard.
i'm getting an error i have never seen.
here is the code that is involved with buffer2Run-Time Check Failure #2 - Stack around the variable 'buffer2' was corrupted.
any help would be appreciatedCode:char buffer1[128]="Hello World", buffer2[128]; if (send(remoteSocket, buffer1, sizeof(buffer1), 0)==SOCKET_ERROR) { cout<<"Remote socket send Error"<<endl; getch(); exit(1); } int bytesReceived = recv(localSocket, buffer2, sizeof(buffer2), 0); buffer2[bytesReceived]='\0'; cout<<buffer2; cout<<endl; getch();
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
never mind i fixed it with
Code:char buffer1[128]="Hello World", buffer2[128]; if (send(remoteSocket, buffer1, sizeof(buffer1), 0)==SOCKET_ERROR) { cout<<"Remote socket send Error"<<endl; getch(); exit(1); } int bytesReceived = recv(localSocket, buffer2, sizeof(buffer2), 0); buffer2[bytesReceived-1]='\0'; cout<<buffer2; cout<<endl; getch();
Last edited by xviddivxoggmp3; 08-13-2005 at 08:09 PM.
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
Two concerns about buffer2:
1) Are you allowed to initialize multiple char arrays on one line? I don't see why not, but it's possible.
2) If you receive 128 bytes, your code will run:
Which is obviously unacceptable since it's only indexed up to 127.Code:buffer2[128] = '\0';
i just figured that out.
check the post before yours.
thanks though.
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
Sorry - you beat me to it.
no worries, i have another question if you are willing to look at it.
if i want to convert this into an online chat program.
(1) is there a way to have the chat display sequentially on a command line interface?
i haven't mastered windows programming yet, i'm only good with console programs.
I want the full communication to resemble a sequential list of text like irc or other im programs.
i can only think of a way to post text then ask for input then post.
it would be anything like a sequential chat.
Last edited by xviddivxoggmp3; 08-13-2005 at 08:21 PM.
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
sizeof is not teh saem as strlen, Are you sure you want to send 128bytes even though you only use strlen("hello world") of them?
so... you are good at bothOriginally Posted by xviddivxoggmp3
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
good call, i will correct that now. are you willing to look at the rest of my code to tell me what other inefficient errors I made?sizeof is not teh saem as strlen, Are you sure you want to send 128bytes even though you only use strlen("hello world") of them?
another question i have. how can i keep receiving and printing while not sending?
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
i tried strlen(buffer), and it didn't work. it stopped anything from being transmitted.
Code:char buffer1[128]="Hello World", buffer2[128]; if (send(remoteSocket, buffer1, strlen(buffer1) , 0)==SOCKET_ERROR) { cout<<"Remote socket send Error"<<endl; getch(); exit(1); } int bytesReceived = recv(localSocket, buffer2, strlen(buffer2) , 0); buffer2[bytesReceived-1]='\0'; cout<<buffer2; cout<<endl; getch();
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
You are going to have to be more specific. That sent strlen(buffer1) worth of bytes regardless of what your test may have shown.i tried strlen(buffer), and it didn't work. it stopped anything from being transmitted.
Do you have a testcase to show what you mean?
http://ortdotlove.net/testcase.html to learn what a testcase is.
I have a feeling you are probably getting confused because you proably don't know C/C++ as well as you should and sockets are a bit more complex than you had in mind.
What do you mean here? Nobody says you have to send in order to recv? Are you trying to keep on calling recv and not getting any bytes? If this is the case then you have to realize that it takes time to send data over a socket and this time is several orders of magnitude slower than it takes for your code to reach the next recv call. So you try to recv with nothing there to you don't get any data. You need to learn about 'select' and 'poll'. They let you wait until there is something there to read so you don't waste calls on an socket with nothing around.another question i have. how can i keep receiving and printing while not sending?
thanks for your vote of confidence.
i'm sorry the last post was only half complete due to i'm posting while at work.
tell me if this is not correct for the conversion.
the reason why it was destroying my last data transfer was due to i was using strlen on my receive buffer, and it basically said receive an amount equivalent to an empty buffer. so nothing was received.Code:send(remoteSocket, buffer1, (strlen(buffer1)+1) , 0)==SOCKET_ERROR)
but you did have some constructive comments in regards to the strlen(), so thanks for that.
I think my next question that wasn't thoroughly asked earlier was, how would i have two processes running at the same time? i read a little on and found the terms mult-threaded.
i'm assuming this is how i could receive and send at the same time. does anyone have a really good multi-thread link for me to read, so i can determine if this is what i'm looking for?
Last edited by xviddivxoggmp3; 08-14-2005 at 11:23 PM.
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu