[英]How can I link a C websocket server running on AWS Linux with the client on a virtual machine locally?
I recently wrote an echoserver / echoclient program in C for the online class I'm taking (Graduate Introduction to Operating Systems, here ).我最近在 C 中为我正在学习的在线 class 编写了一个 echoserver / echoclient 程序(这里是操作系统研究生简介)。 I was able to complete it with the help of (and modification from Beej's Network guide ( here ). I can run it just fine on my Ubuntu 20.04 virtual machine, running on my Windows 10 laptop. However, I'm trying to run the echoserver on an AWS Linux instance and the echoclient from the Ubuntu VM, as my end goal is building a client program that has a central server data repository. However, I'm running into issues where I start the echoserver C code on the AWS EC2 instance through SSH-ing by PuTTy, then I run the echoclient on the Ubuntu VM, but it can't connect (the error I receive on the client side is that it failed the connect
phase of the socket call). I've tried the following steps:我能够在(以及 Beej 的网络指南(此处)的修改)的帮助下完成它。我可以在我的 Ubuntu 20.04 虚拟机上运行它,运行在我的 Windows 10 笔记本电脑上。但是,我正在尝试运行echoserver on an AWS Linux instance and the echoclient from the Ubuntu VM, as my end goal is building a client program that has a central server data repository. However, I'm running into issues where I start the echoserver C code on the AWS EC2通过 PuTTy 进行 SSH-ing 实例,然后我在 Ubuntu VM 上运行 echoclient,但它无法连接(我在客户端收到的错误是它在套接字调用的connect
阶段失败)。我试过了以下步骤:
curl ifconfig.me
on my Ubuntu machine编辑 EC2 实例安全配置的入站规则以允许来自curl ifconfig.me
地址的“所有 TCP”连接telnet <AWS Public IP> <PortNo>
- which led to "Connection Refused" error通过telnet <AWS Public IP> <PortNo>
测试端口访问 - 这导致“连接被拒绝”错误I've looked through the AWS pages ( here ) as well as multiple developer / SO threads (best one I found so far here ) and I just can't seem to figure out out.我浏览了 AWS 页面( 此处)以及多个开发人员/SO 线程(我在此处找到的最佳线程),但我似乎无法弄清楚。 If anyone could help me out, I'd really appreciate it.如果有人可以帮助我,我将不胜感激。 I'm happy to post my server & client code if that would be of help.如果有帮助,我很乐意发布我的服务器和客户端代码。
Figured it out: was missing the following line of code in my server.想通了:在我的服务器中缺少以下代码行。
hints.ai_flags = AI_PASSIVE;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.