绑定失败。错误:地址已在使用 [英] bind failed. Error: Address already in use

查看:259
本文介绍了绑定失败。错误:地址已在使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我Socket编程很新,LINUX,C ..这是程序的Socket我绑定一部分

I am new in Socket programming,Linux ,C.. This is my Bind part of the Socket program

//Bind
if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
    //print the error message
    perror("bind failed. Error");
    return 1;
}
puts("bind done");

但它给

用户桌面:〜/ socket_programming $ ./server

插座创建

绑定失败。错误:地址已在使用

我不知道如何解决这个问题..请给我一个解决方案。

I don't know how to fix this problem.. Please give me a solution..

推荐答案

该错误通常意味着你试图打开的端口被已被另一个应用程序尝试使用netstat来查看哪些端口是开放的,然后使用一个可用端口。

The error usually means that the port you are trying to open is being already used by another application try using netstat to see which ports are open and then use an available port.

另外,请检查您是否绑定到正确的IP地址(我假定这将是localhost)

Also check if you are binding to the right ip address (I am assuming it would be localhost)

这篇关于绑定失败。错误:地址已在使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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