アプリ版:「スタンプのみでお礼する」機能のリリースについて

VxWorks 6.4ソケット接続について。
connectWithTimeout()でサーバへの接続ができません。戻り値が常にERROR。connect() だとうまくいくのですが、何が原因なのでしょうか?
下記にソースコードを提示します

#include "vxWorks.h"
#include "stdio.h"
#include "stdlib.h"
#include "types.h"
#include "net/mbuf.h"
#include "socket.h"
#include "net/socketvar.h"
#include "socklib.h"
#include "inetLib.h"
void tmain( void )
{
#define IP_ADDRS_SERVER "193.9.200.2"
struct timeval TimeOut;
struct sockaddr_in Srv;
static int nSock;
int ret=0;
int status=0;

do{
nSock = socket(AF_INET, SOCK_STREAM, 0);

TimeOut.tv_sec = 10L ;
TimeOut.tv_usec = 0L ;

Srv.sin_family = AF_INET ;
Srv.sin_port = htons(12000) ;
Srv.sin_addr.s_addr = inet_addr(IP_ADDRS_SERVER) ;

//↓これだとうまくいく↓
// if ( connect(nSock, (struct sockaddr *)&Srv, sizeof(Srv) ) == ERROR ) {
//↓これだとうまくいかない↓
if ( connectWithTimeout(nSock, (struct sockaddr *)&Srv, sizeof(Srv), &TimeOut ) == ERROR ) {
ret = close(nSock);
} else {
status=1;
}
}while(status==0);
}

A 回答 (1件)

質問のVxWorks 6.4に該当するかはよく分からないのですが、以下のマニュアルにこういう文があります。


http://www.akae.cn/study/ebook/wrs/workbench/pla …
「4.9.2 API Mapping
connectWithTimeout is carried forward, but is not supported for AF_INET and AF_INET6 address families. Use select( ) to specify the timeout value for the socket descriptor.」
つまり、AF_INETでは使えない、select()で対処せよ、ということみたいですね。

参考URL:http://www.akae.cn/study/ebook/wrs/workbench/pla …
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!


このQ&Aを見た人がよく見るQ&A