C++ Builder UDP programming

This is a discussion on C++ Builder UDP programming within the Networking/Device Communication forums, part of the General Programming Boards category; Hey there! I'm experimenting with UDP communications in these times, and I'm a bit stuck. I tried to use the ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    C++ Builder UDP programming

    Hey there!

    I'm experimenting with UDP communications in these times, and I'm a bit stuck. I tried to use the built in components in C++ Builder (5.0 by the way), but it does not work.

    Could you please help me in this? I don't know which sockets to place, Server, Client, NMUDP, how to interface withit, and stuff.

    The thing I'd like to do is the following: Listen on a specific UDP port, and when a packet arrives to my PC I'd like to get the databytes sent in the UDP frame.

    It's kinda so painful because I made a microcontroller communicate with the UDP protocol (and I suppose that's a much harder job), and now I'm stuck with just a stupid little problem with this.

    So please help me, just as you did in the past. Thanks for that again.

    Han

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    I suppose you really ought to test your quick PC implementation with a simulation of your embedded microcontroller before you actually connect it to the microcontroller.

    How do you know that it's sending valid packets?

    You should really run ethereal to see if you're getting anything at all sent.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    Well I use Ethereal to see the incoming packets. The protocol is okay, the IPs are okay, although the checksum is not very good yet. But anyway, I'd be happy with anything in my software that shows me that something's in. So what I'm looking for are more like advices than components. I trust that the components supplied with C++ Builder are good enough for the job. I just don't know how to use them.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    Well using something pre-crafted seems hard work to me, since the examples you see in say Beej are only about 30 lines long to begin with (connect and read a packet).

    At least then you'd be able to post what you tried in a nice simple code example rather than all the excess baggage of some bloated object which few here will be able to help you with.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    I cannot really post anything, since I don't really understand how this works.

    There are the following components available in C++ Builder (supplied with the software):
    ClientSocket
    ServerSocket
    NMUDP

    As far as I know, the ClientSocket, and ServerSockets are to make a TCP/IP connection to a server. So it seems to me that I'll have to place a ClientSocket, and an NMUDP component to my software. OR do I only have to place an NMUDP component, since it contains a "remote host" property, which is the IP address of the remote host?

    I tried it only with the NMUDP component, but I didn't recieve the packet I saw on Ethereal. (Does it mean that the checksum of the packed is checked upon arrival?)

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    I've solved the problem. I made a little program which sends a data packet to a given IP, localport, etc. Then I got knee deep into the source code of the microcontroller's UDP implementation (with a RTL8019AS IC), and corrected some bugs.
    And nearly that was it. Now, it is working perfectly in both directions (PC to device, device to PC). So I'm done with this problem. If I have questions regarding UDP, I'll post them here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with UDP
    By AlexS in forum C# Programming
    Replies: 0
    Last Post: 07-07-2009, 07:21 PM
  2. simultaneously waiting for data on FIFO and UDP using select call
    By yogesh3073 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-05-2007, 09:53 AM
  3. THE END - Borland C++ Builder, Delphi, J Builder?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-28-2006, 11:23 PM
  4. Traceroute using UDP and ICMP
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-09-2002, 08:09 PM
  5. Traceroute using UDP + ICMP
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 08-05-2002, 11:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21