Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

I'm puzzled by another issue rising from the use of ISocket_connect.
I modified the codes from the sample netdiagnostic.c in order to learn how to use socket. But when I used ISocket_connect to reach a server, there seemed no packets sent out, no networking movement although the returning value was AEE_NET_SUCCESS. The function Echoer_TCPConnected was not called by ISOCKET_connect.

Was the TCP connection really established after calling ISOCKET_connect?
How could I write to the sockets and let it send out packats then?

My codes:

static void Connect_Start(CityMapApp * pApp)
{
char IPAddr[15] = "127.0.0.1";
INAddr addrs;
int nErr;

pApp->m_pISocket = INETMGR_OpenSocket(pApp->m_pINetMgr, AEE_SOCK_STREAM);

if (pApp->m_pISocket == NULL) {
ND_Print(pApp, "** OpenSocket Failed: Error %d\n", INETMGR_GetLastError(pApp->m_pINetMgr));
return;
}

if(INET_ATON(IPAddr,&addrs)){
nErr = ISOCKET_Connect(pApp->m_pISocket, addrs, 9000, Echoer_TCPConnected, pApp);
}

if (nErr != AEE_NET_SUCCESS) {
ND_Print(pApp, "** fail connection: Error %d\n", ISOCKET_GetLastError(pApp->m_pISocket));
ReleaseObj((void**)&pApp->m_pISocket);
} else {
ND_Print(pApp, "** connecting...\n");
}

static void Echoer_TCPConnected(void *p, int nErr)
{
CityMapApp * pApp = (CityMapApp *)p;

if ((nErr == AEE_NET_SUCCESS) || (nErr == AEE_NET_EISCONN)){
pApp->m_nTCPIdx = 0;
Echoer_TCPWrite(pApp);
} else {
CM_ReleaseObj((void**)&pApp->m_pISocket);
}

Hello All,
I am facing the same problem. I tried the Netdiagnostic sample and it is also giving the same error( error no 577, General Failure). In The callback function of ISCOKET_Connect, it gives the error.
How is this possible that the sample prob is not working...
Have u got the solution, HooverLu?
waiting for responce.
Anand.

Hello All,
I am facing the same problem. I tried the Netdiagnostic sample and it is also giving the same error( error no 577, General Failure). In The callback function of ISCOKET_Connect, it gives the error.
How is this possible that the sample prob is not working...
Have u got the solution, HooverLu?
waiting for responce.
Anand.

No, Anand. I haven't got a clue.

No, Anand. I haven't got a clue.

Hey HooverLu,
I said, am facing the same problem. I am also trying that example and I am getting the same error and haven't got the solution yet. I asked u if u have got the solution after placing the query. Unfortunately, It was not a clue.
I will let u know if I get any information regarding this matter.
Sorry for the trouble!!!
Anand.

Hey HooverLu,
I said, am facing the same problem. I am also trying that example and I am getting the same error and haven't got the solution yet. I asked u if u have got the solution after placing the query. Unfortunately, It was not a clue.
I will let u know if I get any information regarding this matter.
Sorry for the trouble!!!
Anand.

I advice you convert the port number.
For example
(9000)dec -> (2328)hex
23 28 -> 28 23
nErr = ISOCKET_Connect(pApp->m_pISocket, addrs, 9000,
-> nErr = ISOCKET_Connect(pApp->m_pISocket, addrs, 0x2823,

I advice you convert the port number.
For example
(9000)dec -> (2328)hex
23 28 -> 28 23
nErr = ISOCKET_Connect(pApp->m_pISocket, addrs, 9000,
-> nErr = ISOCKET_Connect(pApp->m_pISocket, addrs, 0x2823,

Use:
HTONS(Port)
to convert the port.

Use:
HTONS(Port)
to convert the port.

From documentation:
The parts of an internet IP endpoint, address and port. INAddr and INPort denote network byte-order values for the IP address and port of an IP socket or endpoint.
that could be your possible problem.
regards
ruben

From documentation:
The parts of an internet IP endpoint, address and port. INAddr and INPort denote network byte-order values for the IP address and port of an IP socket or endpoint.
that could be your possible problem.
regards
ruben