473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

issues on testing udp chat on same machine

hi, im creating a program that allows users to chat using udp sockets..

as a general description, what i did was fork a child process that sends a udp datagram via an ephemeral port while the parent listens on some specific port..

to test the program, i am using two different terminals on the same machine..

when i run the program on one terminal, i set the ip address to 127.0.0.2.. then, i run the same program in another terminal with ip address 127.0.0.1.. so when i send a message to 127.0.0.2 from 127.0.0.1, i indicate 127.0.0.2 as the destination.sin_addr (with the proper conversion of course)..

the problem is, when the program with ip 127.0.0.2 receives the datagram and i try to display the sender's ip (supposedly 127.0.0.1), it displays 127.0.0.2! the same goes when i send to 127.0.0.1 from 127.0.0.2 : the sender's ip displayed is 127.0.0.1 instead of 127.0.0.2!

1) is this an issue because i am only using loopback addresses? will this turn out all right when i am running the program on different computers and not using a loopback address?

2) and also, is there a way to specify on which port i would like to send a message to (and not on some ephemeral port)?

3) lastly, if i bind some program's, say program 1's, parent's socket (the listener) to an ephemeral port, and program 2's child (the talker) wants to send to program 1, what port will i indicate as the destination port? is there a way to know to what ephemeral port program 1's listener is bound to?

i dont have enough resources to setup a network so i am only limited to testing on the same machine :(

thanks a lot!
Mar 9 '08 #1
2 2216
sicarie
4,677 Expert Mod 4TB
hi, im creating a program that allows users to chat using udp sockets..
Why use UDP? You're not streaming anything, so TCP would be a much more logical choice. Using UDP you have no receipt-verification process or re-sending of corrupt packets. This means entire chunks of the conversation could be lost without you knowing it.
as a general description, what i did was fork a child process that sends a udp datagram via an ephemeral port while the parent listens on some specific port..

to test the program, i am using two different terminals on the same machine..

when i run the program on one terminal, i set the ip address to 127.0.0.2.. then, i run the same program in another terminal with ip address 127.0.0.1.. so when i send a message to 127.0.0.2 from 127.0.0.1, i indicate 127.0.0.2 as the destination.sin_addr (with the proper conversion of course)..

the problem is, when the program with ip 127.0.0.2 receives the datagram and i try to display the sender's ip (supposedly 127.0.0.1), it displays 127.0.0.2! the same goes when i send to 127.0.0.1 from 127.0.0.2 : the sender's ip displayed is 127.0.0.1 instead of 127.0.0.2!

1) is this an issue because i am only using loopback addresses? will this turn out all right when i am running the program on different computers and not using a loopback address?
Hard to say without seeing your code.
2) and also, is there a way to specify on which port i would like to send a message to (and not on some ephemeral port)?
It is possible, but as I haven't done it recently, I'm going to recommend using Google.
3) lastly, if i bind some program's, say program 1's, parent's socket (the listener) to an ephemeral port, and program 2's child (the talker) wants to send to program 1, what port will i indicate as the destination port? is there a way to know to what ephemeral port program 1's listener is bound to?
Do you really need to know? Isn't all this stuff handled for you? You could always do a netstat on the machine you're unsure of, but there is also probably an easier way if you were to use the API of the OS this will be running on.
i dont have enough resources to setup a network so i am only limited to testing on the same machine :(

thanks a lot!
Mar 9 '08 #2
thanks a lot for the reply.. i'll look into TCP..
Mar 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: GrantS | last post by:
I need urgent help. Done OK for a newbie getting automation of Windows Messenger into a Winform C# app but have three problems that I urgently need pointers to. Point 1 and 2 are the same issue, I...
16
by: clintonG | last post by:
I haven't installed VS2005 B2 yet. My main concern is installing VS2005 B2 on the XP Pro machine where VSN2003 already exists. Am I asking for trouble? Your comments... <%= Clinton Gallagher
2
by: Tom Wells | last post by:
My server admin and I are trying to figure out how to get impersonation working to be able to upload a file from the client browser thru the web server to a network file server. My network ID for...
3
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling...
1
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications...
25
by: Nathan Sokalski | last post by:
As we all know, IE7 is now available. However, it also cannot be installed side by side with IE6. This makes it very hard to test pages on both versions using the same machine. I am guessing that...
0
by: Gabriel Genellina | last post by:
En Mon, 09 Jun 2008 15:32:00 -0300, Marcelo de Moraes Serpa <celoserpa@gmail.comescribió: I don't think it's a problem with ElementTree. Perhaps you are writing the same (global) configuration...
3
by: John Dalberg | last post by:
I am looking for an asp.net based chat software. I have looked at some (asp.net and php based) and they consist usually of a javascript piece where the web user (visitor) initiates a chat from a...
4
by: =?Utf-8?B?dmlwZXJ4MTk2Nw==?= | last post by:
We are having an issue with an application we are developing. We have a Legacy COM DLL in C++ that we have converted to Visual Studio 2008. This COM DLL has methods that are calling Managed C#...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.