CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    india
    Posts
    14

    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

  2. #2
    Join Date
    Mar 2001
    Location
    Xi'an Shaanxi, China
    Posts
    60
    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.

  3. #3
    Join Date
    Apr 2003
    Location
    Morelia, Mexico
    Posts
    40
    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);}

  4. #4
    Join Date
    Mar 2001
    Location
    Xi'an Shaanxi, China
    Posts
    60
    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.

  5. #5
    Join Date
    Apr 2003
    Location
    Morelia, Mexico
    Posts
    40
    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
  •  





Click Here to Expand Forum to Full Width

Featured