?
Solved

C++ send lines of text to an UDP-server

Posted on 2010-11-10
6
Medium Priority
?
707 Views
Last Modified: 2012-08-13
Hi guys. I have created this php-script:
<?php
$user_name1 = 3064;
$ip_adr = "192.168.50.64";
$sip_port = 2058;
$message = $argv[1];
$length = strlen($message);

$sippacket = "MESSAGE sip:$user_name1@$ip_adr:$sip_port SIP/2.0
Via: SIP/2.0/UDP 192.168.50.2:47942;branch=z9hG4bK.1a041dd5;rport;alias
To: sip:$user_name1@$ip_adr:$sip_port
Call-ID: 751288264@192.168.50.2
CSeq: 1 MESSAGE
Content-Type: text/plain
Max-Forwards: 70
User-Agent: PHP script
From: sip:phpscript@192.168.50.2:2057;tag=2cc7bfc8
Content-Length: $length

$message";

$fp = fsockopen("udp://$ip_adr", $sip_port, $errno, $errstr);
if (!$fp) {
   echo "ERROR: $errno - $errstr<br />\n";
} else {
   fwrite($fp, $sippacket);
   fclose($fp);
}
?>

Open in new window


...which sends these lines of text:
MESSAGE sip:$user_name1@$ip_adr:$sip_port SIP/2.0
Via: SIP/2.0/UDP 192.168.50.2:47942;branch=z9hG4bK.1a041dd5;rport;alias
To: sip:$user_name1@$ip_adr:$sip_port
Call-ID: 751288264@192.168.50.2
CSeq: 1 MESSAGE
Content-Type: text/plain
Max-Forwards: 70
User-Agent: PHP script
From: sip:phpscript@192.168.50.2:2057;tag=2cc7bfc8
Content-Length: $length

$message

Open in new window


... to 192.168.50.64 UDP port 2058. How can I accomplish this with C++ in a Mac OS X environment? I am using netbeans as IDE and please note that some of the values in the text are variables.

I am totally new to C++ :)
0
Comment
Question by:Billetkontoret
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 32

Accepted Solution

by:
phoffric earned 2000 total points
ID: 34105312
0
 
LVL 2

Author Comment

by:Billetkontoret
ID: 34105396
When you say unix and windows, you mean Mac OS X as well?
0
 
LVL 32

Expert Comment

by:phoffric
ID: 34105644
"Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc."
    http://en.wikipedia.org/wiki/Mac_OS_X

So, I would expect that if you review the unix-based links, then you will be close to what your Mac OS X documentation provides.
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 34109707
If you can use a command line tool instead of a c++ compiled program, you could see netcat[1]



[1] http://netcat.sourceforge.net/
0
 
LVL 40

Expert Comment

by:evilrix
ID: 34824133
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question