c / c ++中的udp客户端服务器应用程序 [英] udp client server application in c/c++

查看:115
本文介绍了c / c ++中的udp客户端服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我是网络编程的初学者,所以我很抱歉,如果我的问题看起来非常简单而且对你很愚蠢......

我的第一个任务是运行一个简单的udp客户端服务器应用程序,通常我看到的示例程序是在命令行参数的帮助下运行的,但是在基本级别我不想这样做,所以我需要用一些IP地址绑定客户端(srever) '的IP地址和端口号)...

如何在代码中执行此操作...以便我无需在命令提示符下运行它...

如果我得到了服务器和客户端的答案,那我真的很有意思。

再次为这样一个原始问题道歉:(

hey,
I am a beginner to network programming so my apologies if my question seems very trivial and dumb to you...
my first task is to run a simple udp client server application,usually the sample programs that I see run with the help of command line arguments,but being on the basic level I do not want to do that,so I need to bind the client with some IP address(srever''s IP address and port number)...
how can I do that in code...so that I need not run it from command prompt...
I would be really thatnkful if I got the answer for both server and client.
again my apologies for a primitive question like this:(

推荐答案

好吧,如果你不想在你的应用程序中处理命令行参数(但为什么?)然后在代码中硬连接这些参数。例如,使用这个代码示例 [ ^ ],从<更改(在客户端代码中) br />
Well, if you don''t want to deal with command line arguments (but why?) in your application then hard-wire such parameters in code. For instance, using this code sample[^], change (in the client code) from
h = gethostbyname(argv[1]);



to


to

h = gethostbyname("127.0.0.1");


这篇关于c / c ++中的udp客户端服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆