|
楼主 |
发表于 2004-7-29 09:39:09
|
显示全部楼层
[quote:854564bdad=""][EINVAL] The socket is already bound to an address,
the socket has been shut down, addrlen is a
bad value, or an attempt was made to bind()
an AF_UNIX socket to an NFS-mounted (remote)
name.
远程?楼主想用域套接字绑定网络地址?[/quote]不是的,域套接字绑定的是本地临时文件用来进程间通信。下面是部分代码:
int mSocket=-1;
char * mPath = "/tmp/stpc_SHTExecution";
struct stat buf;
if(stat((const char*)mPath, &buf) == 0)
{
if(remove((const char*)mPath) != 0)
{
// removal failed
fprintf(stderr, "Warning: Cannot remove socket communication file %s -
please remove the file manually.", (const char*)mPath);
}
}
mSocket = socket(AF_UNIX, SOCK_STREAM, 0);
if(mSocket != -1)
{
// bind socket
struct sockaddr_un pa_addr;
pa_addr.sun_family=AF_UNIX;
strcpy(pa_addr.sun_path, (const char*)mPath);
int ret=bind(mSocket,(struct sockaddr*) &pa_addr, sizeof(struct
sockaddr_un));
if(ret==-1)
printf("*******************Bind socket :%d failed!\n",mSocket);
我怀疑是我的系统设置与CLEARCASE 对代码管理时设置方面存在冲突。因为我在本地执行这段代码时是没问题的。一旦我与clearcase相连,BIND() 就失败。不知大家对这种情况有何建议。。。。谢了。 |
|