socket意思 什么意思

socket的中文意思
沪江词库精选socket是什么意思、英语单词推荐、用法及解释、中英文句子翻译、英语短语、英音发音音标、美音发音音标。
英音 [ 's?kit ] ; 美音 [ 's?:kit ] 名词
1.(电源)插座2.(电器上的)插口,插孔,管座3.托座,孔穴,窝,糟
词形变化:时态:。
Aa blind passage.
封死的孔;死路
Three prong socket
Anan undependable lamp socket.
一个靠不住的工人,性能不清的电灯插座
Connect the release switch to the remote control socket of the camera.
把释放开关接到相机遥控插口。
Assemble joint by inserting tube into socket hard against the stop.
在进行连接组装时,要将管道插入管套直到遇到阻挡为止。
Use Secure Socket Layer(SSL) or TLS for outgoing messages.
对发送消息使用安全套接字层(SSL)或TLS。
A non-blocking socket operation could not be completed immediately.
无法立即完成一个非阻挡性套接字操作。
Do Not force the CPU into the socket to prevent bending the pins and damaging the CPU.
若您发现您的处理器无法放入时,请勿用力将之压下以免折断处理器针角或造成损坏
Socket is not connected
套接字未被连接
Faucet Socket
a bony hollow into which a structure fits
a receptacle into which an electric device can be inserted
receptacle where something (a pipe or probe or end of a bone) is inserted
n. 非常卓越的东西
n. 决定性打击
n. 决定性的打击,突出的人
1. 短袜,鞋的衬底
1. 重击,猛投,给…穿袜
2.【口】存钱
a. 社会和宗教的
2016socket是什么意思由沪江网提供。新手园地& & & 硬件问题Linux系统管理Linux网络问题Linux环境编程Linux桌面系统国产LinuxBSD& & & BSD文档中心AIX& & & 新手入门& & & AIX文档中心& & & 资源下载& & & Power高级应用& & & IBM存储AS400Solaris& & & Solaris文档中心HP-UX& & & HP文档中心SCO UNIX& & & SCO文档中心互操作专区IRIXTru64 UNIXMac OS X门户网站运维集群和高可用服务器应用监控和防护虚拟化技术架构设计行业应用和管理服务器及硬件技术& & & 服务器资源下载云计算& & & 云计算文档中心& & & 云计算业界& & & 云计算资源下载存储备份& & & 存储文档中心& & & 存储业界& & & 存储资源下载& & & Symantec技术交流区安全技术网络技术& & & 网络技术文档中心C/C++& & & GUI编程& & & Functional编程内核源码& & & 内核问题移动开发& & & 移动开发技术资料ShellPerlJava& & & Java文档中心PHP& & & php文档中心Python& & & Python文档中心RubyCPU与编译器嵌入式开发驱动开发Web开发VoIP开发技术MySQL& & & MySQL文档中心SybaseOraclePostgreSQLDB2Informix数据仓库与数据挖掘NoSQL技术IT业界新闻与评论IT职业生涯& & & 猎头招聘IT图书与评论& & & CU技术图书大系& & & Linux书友会二手交易下载共享Linux文档专区IT培训与认证& & & 培训交流& & & 认证培训清茶斋投资理财运动地带快乐数码摄影& & & 摄影器材& & & 摄影比赛专区IT爱车族旅游天下站务交流版主会议室博客SNS站务交流区CU活动专区& & & Power活动专区& & & 拍卖交流区频道交流区
白手起家, 积分 138, 距离下一级还需 62 积分
论坛徽章:0
如题。书上所说,-1是出错。正常是0.但我的代码会有返回1.
#include &unp.h&
#define MAXPORT 1000
int main(int argc,char **argv){
&&&&&&&&int sockfd,i,ret;
&&&&&&&&struct sockaddr_in& && &servaddr;
&&&&&&&&if (argc != 2)
&&&&&&&&&&&&&&&&err_quit(&usage: a.out &IPaddress&&);
&&&&&&&&if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) & 0)
&&&&&&&&&&&&&&&&err_sys(&socket error&);
&&&&&&&&bzero(&servaddr, sizeof(servaddr));
&&&&&&&&servaddr.sin_family = AF_INET;
&&&&&&&&if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) &= 0)
&&&&&&&&err_quit(&inet_pton error for %s&, argv[1]);
&&&&&&&&for(i=1;i&MAXPORT;i++){
&&&&&&&&&&&&&&&&printf(&conneting to port %d \n&,i);
&&&&&&&&&&&&&&&&servaddr.sin_port& &= htons(i);
&&&&&&&&&&&&&&&&if (ret=connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) &= 0)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&printf(&port %d is open \n&,i);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&printf(&return %d\n&,ret);
&&&&&&&&exit(0);
open的端口返回的都是1,而未开放的端口返回的是0。
conneting to port 12
conneting to port 13
port 13 is open
我的是ubuntu7.10
&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp
论坛徽章:0
扫描端口?
白手起家, 积分 138, 距离下一级还需 62 积分
论坛徽章:0
哪位大哥知道的,指点一下啊。
白手起家, 积分 29, 距离下一级还需 171 积分
论坛徽章:0
你可以把errorno在控制台上输出看看阿!
Technical Reference: Communications, Volume 2
connect Subroutine
& && & Connects two sockets.
& && & Standard C Library (libc.a
& && & #include &sys/socket.h&
& && & int connect ( Socket, Name, NameLength)
& && & int S
& && & const struct sockaddr *N
& && & socklen_t NameL
Description
& && & The connect subroutine requests a connection between two sockets. The kernel sets up the communication link between the
& && & both sockets must use the same address format and protocol.
& && & If a connect subroutine is issued on an unbound socket, the system automatically binds the socket. The connect subroutine
& && & can be used to connect a socket to itself. This can be done, for example, by binding a socket to a local port (using bind)
& && & and then connecting it to the same port with a local IP address (using connect).
& && & The connect subroutine performs a different action for each of the following two types of initiating sockets:
& && & *& & If the initiating socket is SOCK_DGRAM, the connect subroutine establishes the peer address. The peer address
& && && && &identifies the socket where all datagrams are sent on subsequent send subroutines. No connections are made by this
& && && && &connect subroutine.
& && & *& & If the initiating socket is SOCK_STREAM or SOCK_CONN_DGRAM, the connect subroutine attempts to make a connection to
& && && && &the socket specified by the Name parameter. Each communication space interprets the Name parameter differently. For
& && && && &SOCK_CONN_DGRAM socket type and ATM protocol, some of the ATM parameters may have been modified by the remote station,
& && && && &applications may query new values of ATM parameters using the appropriate socket options.
& && & *& & In the case of a UNIX(R) domain socket, a connect call only succeeds if the process that calls connect has read and
& && && && &write permissions on the socket file created by the bind call. Permissions are determined by the umask& value of the
& && && && &process that created the file.
Implementation Specifics
Parameters
& && & Socket
& && && && &Specifies the unique name of the socket.
& && & Name
& && && && &Specifies the address of target socket that will form the other end of the communication line
& && & NameLength
& && && && &Specifies the length of the address structure.
Return Values
& && & Upon successful completion, the connect subroutine returns a value of 0.
& && & If the connect subroutine is unsuccessful, the system handler performs the following functions:
& && & *& & Returns a value of -1 to the calling program.
& && & *& & Moves an error code, indicating the specific error, into the errno global variable.
Error Codes
& && & The connect subroutine is unsuccessful if any of the following errors occurs:
& && & Value
& && && && &Description
& && & EADDRINUSE
& && && && &The specified address is already in use. This error will also occur if the SO_REUSEADDR socket option was set and the
& && && && &local address (whether specified or selected by the system) is already in use.
& && & EADDRNOTAVAIL
& && && && &The specified address is not available from the local machine.
& && & EAFNOSUPPORT
& && && && &The addresses in the specified address family cannot be used with this socket.
& && & EALREADY
& && && && &The socket is specified with O_NONBLOCK or O_NDLAY, and a previous connecttion attempt has not yet completed.
& && & EINTR
& && && && &The attempt to establish a connection was interrupted by delivery of a si the connection will be
& && && && &established asynchronously.
& && & EACCESS
& && && && &Search permission is denied on a component of the path prefix or write access to the named socket is denied.
& && & ENOBUFS
& && && && &The system ran out of memory for an internal data structure.
& && & EOPNOTSUPP
& && && && &The socket referenced by Socket parameter does not support connect.
& && & EWOULDBLOCK
& && && && &The range allocated for TCP/UDP ephemeral ports has been exhausted.
& && & EBADF
& && && && &The Socket parameter is not valid.
& && & ECONNREFUSED
& && && && &The attempt to connect was rejected.
& && & EFAULT
& && && && &The Address parameter is not in a writable part of the user address space.
& && & EINPROGRESS
& && && && &The socket is marked as nonblocking. The connection cannot be immediately completed. The application program can
& && && && &select the socket for writing during the connection process.
& && & EINVAL
& && && && &The specified path name contains a character with the high-order bit set.
& && & EISCONN
& && && && &The socket is already connected.
& && & ENETDOWN
& && && && &The specified physical network is down.
& && & ENETUNREACH
& && && && &No route to the network or host is present.
& && & ENOSPC
& && && && &There is no space left on a device or system table.
& && & ENOTCONN
& && && && &The socket could not be connected.
& && & ENOTSOCK
& && && && &The Socket parameter refers to a file, not a socket.
& && & ETIMEDOUT
& && && && &The establishment of a connection timed out before a connection was made.
& && & The following program fragment illustrates the use of the connect subroutine by a client to initiate a connection to a
& && & server's socket.
& && & struct sockaddr_
& && & connect(s,(struct sockaddr*)&server, sun_len(&server));
Related Information
& && & The accept subroutine, bind subroutine, getsockname subroutine, send subroutine, socket, subroutine, socks5tcp_connect
& && & subroutine.
& && & Initiating UNIX Stream Connections Example Program, Sockets Overview, and Understanding Socket Connections in AIX 5L
& && & Version 5.3 Communications Programming Concepts.
白手起家, 积分 138, 距离下一级还需 62 积分
论坛徽章:0
#include &unp.h&
#define MAXPORT 1000
extern int errno;
int main(int argc,char **argv){
&&&&&&&&int sockfd,i,ret;
&&&&&&&&struct sockaddr_in& && &servaddr;
&&&&&&&&if (argc != 2)
&&&&&&&&&&&&&&&&err_quit(&usage: a.out &IPaddress&&);
&&&&&&&&if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) & 0)
&&&&&&&&&&&&&&&&err_sys(&socket error&);
&&&&&&&&bzero(&servaddr, sizeof(servaddr));
&&&&&&&&servaddr.sin_family = AF_INET;
&&&&&&&&if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) &= 0)
&&&&&&&&err_quit(&inet_pton error for %s&, argv[1]);
&&&&&&&&for(i=1;i&MAXPORT;i++){
&&&&&&&&&&&&&&&&printf(&conneting to port %d \n&,i);
&&&&&&&&&&&&&&&&servaddr.sin_port& &= htons(i);
&&&&&&&&&&&&&&&&if (ret=connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) &= 0)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&printf(&port %d is open \n&,i);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&printf(&return %d\n&,ret);
&&&&&&&&&&&&&&&&&&&&&&&&printf(&errno %d,msg %s&,errno,strerror(errno));
&&&&&&&&exit(0);
返回结果:
conneting to port 1
errno 111,msg Connection refusedconneting to port 2
errno 111,msg Connection refusedconneting to port 3
errno 111,msg Connection refusedconneting to port 4
errno 111,msg Connection refusedconneting to port 5
errno 111,msg Connection refusedconneting to port 6
errno 111,msg Connection refusedconneting to port 7
errno 111,msg Connection refusedconneting to port 8
errno 111,msg Connection refusedconneting to port 9
errno 111,msg Connection refusedconneting to port 10
errno 111,msg Connection refusedconneting to port 11
errno 111,msg Connection refusedconneting to port 12
errno 111,msg Connection refusedconneting to port 13
port 13 is open
errno 111,msg Connection refusedconneting to port 14
errno 106,msg Transport endpoint is already connectedconneting to port 15
errno 106,msg Transport endpoint is already connectedconneting to port 16
errno 106,msg Transport endpoint is already connectedconneting to port 17
errno 106,msg Transport endpoint is already connectedconneting to port 18
。奇怪的是它连接失败为什么不返回-1,而返回0.而成功返回的不是0,却是1.这和unp书上的意思相左啊。网上其他的也都是提到返回-1为出错。0为正常。
白手起家, 积分 138, 距离下一级还需 62 积分
论坛徽章:0
顶啊。还没人出来解答啊
白手起家, 积分 26, 距离下一级还需 174 积分
论坛徽章:0
你的if 句少写了一个()
&&if( (ret=connect(sockfd, (SA *) &servaddr, sizeof(servaddr)))&=0)
你再试一下
论坛徽章:3
if (ret=connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) &= 0)
=的优先级低,所以........
白手起家, 积分 138, 距离下一级还需 62 积分
论坛徽章:0
果然是这问题。多谢兄弟们
白手起家, 积分 36, 距离下一级还需 164 积分
论坛徽章:0
是因为你没有设置你的socket可以重复利用你设置的IP地址,因为当你连续connect同一个IP地址是错误的操作,所以你应该在connect之前加一条setsockopt函数来设置这个SO_REUSEADDR选项
if(setsockopt(sock_fd,SOL_SOCKET,SO_REUSEADDR,&reuseaddr,sizeof(int)) == -1){
& & & & & & & & fprintf(stderr,&set sock option error(SO_REUSEADDR)\n&);
& & & & & & & & exit(-1);
//int reuseaddr=1;socket基本解释n.插座;灯座;窝,穴;[解]眼窝,孔窝vt.把…装入插座;给…配插座变化形式复数sockets第三人称单数sockets过去式socketed过去分词socketed现在分词socketing易混淆的单词Socketsocket的用法和例句It has a socket in its bonnet and needs to be recharged every 100 miles .它的发动机盖下有插座,每100英里需要充电一次。I 've also got a clever plug which you can adapt to fit any socket anywhere .我还有一个万能插头,可以插到任何一种电源插座上。That is what happens when a cfl is plugged into a socket with a dimmer attached .把一根紧凑型荧光灯插入装有调光器的插座,看看会发生什么。Plug-in versions of toyota 's prius hybrid will allow that ground-breaking vehicle to be charged from a mains socket .插电版的丰田prius混合动力车将允许这种开创性的车辆通过电源插座来充电。And , yes , they could even plug themselves into a power socket to recharge their own batteries .而且,没错,它们甚至会将自己插到电源插座上给自己的电池充电。socket相邻词汇
英文热门查询
中文热门查询socket是什么意思
0一头丶0150
SOCKET用于在两个基于TCP/IP协议的应用程序之间相互通信.最早出现在UNIX系统中,是UNIX系统主要的信息传递方式.在WINDOWS系统中,SOCKET称为WINSOCK.两个基本概念:客户方和服务方.当两个应用之间需要采用SOCKET通信时,首先需要在两个应用之间(可能位于同一台机器,也可能位于不同的机器)建立SOCKET连接,发起呼叫连接请求的一方为客户方,接受呼叫连接请求的一方成为服务方.客户方和服务方是相对的,同一个应用可以是客户方,也可以是服务方.在客户方呼叫连接请求之前,它必须知道服务方在哪里.所以需要知道服务方所在机器的IP地址或机器名称,如果客户方和服务方事前有一个约定就好了,这个约定就是PORT(端口号).也就是说,客户方可以通过服务方所在机器的IP地址或机器名称和端口号唯一的确定方式来呼叫服务方.在客户方呼叫之前,服务方必须处于侦听状态,侦听是否有客户要求建立连接.一旦接到连接请求,服务方可以根据情况建立或拒绝连接.连接方式有两种,同步方式(Blocking)和(noBlocking).客户方发送的消息可以是文本,也可以是二进制信息流.当客户方的消息到达服务方端口时,会自动触发一个事件(event),服务方只要接管该事件,就可以接受来自客户方的消息了.
为您推荐:
插座,,插槽的意思,,常说的socket AM2
就是AMD主板上的AM2
cpu插槽,,socekt 775
就是现在intel现在用的最广泛的775 CPU插槽,,应为socket 775是采用是点接触式取代了传统的针角式所以 socekt 775又叫 LGA 775
socket是插座,插槽的意思,电脑CPU座上一般可以看到
socket['s??kit]n.孔, 洞, 窝, 凹处【解】(眼)窝, 腔, 关节窝, 胫骨关节(齿)槽;【地质】牙槽, (烛台的)烛窝;【机】承窝, 座, 套节, 轴孔; 套筒扳手【电】插座, 插口, 管座; 接线片[匣], 穿线环
扫描下载二维码

我要回帖

更多关于 socket意思 的文章

 

随机推荐