简体   繁体   English

如何将在 AWS Linux 上运行的 C websocket 服务器与本地虚拟机上的客户端链接?

[英]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阶段失败)。我试过了以下步骤:

  • Editing the inbound rules of the security configuration of the EC2 instance to allow for 'All TCP' connections from the IP address that comes up when I run curl ifconfig.me on my Ubuntu machine编辑 EC2 实例安全配置的入站规则以允许来自curl ifconfig.me地址的“所有 TCP”连接
  • Changing the network setting of my Ubuntu VM from NAT to Bridged Network将我的 Ubuntu VM 的网络设置从 NAT 更改为桥接网络
  • Testing port access by telnet <AWS Public IP> <PortNo> - which led to "Connection Refused" error通过telnet <AWS Public IP> <PortNo>测试端口访问 - 这导致“连接被拒绝”错误
  • Ensuring that my outgoing ports aren't blocked by following these instructions按照这些说明确保我的传出端口没有被阻止

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.

相关问题 如何在Azure中连接到在Linux虚拟机上运行的mysql服务器 - how to connect to a mysql server running on a linux virtual machine in azure 在 qemu 虚拟机上运行 linux 时如何调试或分析 qemu 代码? - How can I debug or analyze qemu code while running linux on the qemu virtual machine? 如何杀死在 Linux 上本地运行的 Odoo(薄荷) - How can I kill Odoo running locally on Linux (Mint) 如何调试在虚拟机上运行的 kernel 模块? - How can I debug kernel module running on a virtual machine? 为Azure云服务启用HTTPS(运行Linux Server的虚拟机) - Enable HTTPS for Azure cloud service (Virtual Machine running Linux Server) 在Windows Server上以Azure虚拟机运行的Linux容器 - Linux Container on Windows Server Running as Azure Virtual Machine 寻找一种检测我是否在虚拟机(Linux)中运行的好方法 - Looking for a nice way to detect if I am running in a Virtual Machine (Linux) 如何在java中判断程序是否在Windows或Linux计算机上运行? - how can I tell in java if the program is running on a windows or linux machine? 80端口无法加入linux虚拟机 - I can't join linux virtual machine on port 80 如何在Linux机器上锁定C中的目录 - How can I lock a directory in C on a linux machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM