-
April 29th, 2003, 10:56 PM
#1
Socket Programming
Hi all,
i have done an application on socket programming for connection oriented service(TCP)...
and i am familiar with the basics of socket programming...
Now i want to try out UDP..
Can anybody tell the sequence for connection establishment...
The function calls for Sending(Broadcast) .... and Receiving.
if possible pls send me a sample application (if u have any)
Thanks
-
April 29th, 2003, 11:38 PM
#2
For UDP socket, there is no connection established!
And you can use UDP socket as broadcastable or not, just add/remove SO_BROADCAST param when calling CAsyncSocket::SetSockOpt(...).
To send data packet, call CAsyncSocket::SendTo(...);
To recv data packet, call CAsyncSocket::ReceiveFrom(...);
BTW, if you want your program working still well when change TCP to UDP, make a STRONG protocol!
Good luck!
Last edited by David Howe; April 29th, 2003 at 11:41 PM.
Nothing changes, but us.
-
April 29th, 2003, 11:43 PM
#3
I was about to post the same question.
I've done Create and Connect on both ends, but SendTo and ReceiveFrom, seem to not work.
Well, i'm doing the ReceiveFrom in the OnReceive() function, if i shouldn't do it there, then where?
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
-
April 30th, 2003, 12:01 AM
#4
I've done Create and Connect on both ends, but SendTo and ReceiveFrom, seem to not work.
Well, i'm doing the ReceiveFrom in the OnReceive() function, if i shouldn't do it there, then where?
Just put the ReceiveFrom(..) there! To know more about your question, some of your code wanted, perhaps there is something wrong when you creating the UDP socket. And, still have no idea about your word "Connect", what does this mean?
Be sure you have call the AfxSocketInit(), coz I always forget this!
Nothing changes, but us.
-
April 30th, 2003, 02:22 AM
#5
Ohh i found the error, i should not use "Connect()" method, i guess it should just be used for SOCK_STREAM.
I'm using CAsyncSocket btw
A bit of background of the program i'm doing:
My ISP blocked all TCP listen ports, a few days ago i made a thread asking for the possibility of establishing a connection between two peers without a listen port, only answer i got was "no".
So i decided to give it a try with UDP, i know it is unreliable, but that's why i implemente an RWIN and SWIN protocol, very simple, but i think it works so far. I'm yet to implement the CRC checking of the package thou.
Last edited by Luis G; April 30th, 2003 at 02:26 AM.
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|