[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Savannah-users] Query.
From: |
Abhijith N M |
Subject: |
[Savannah-users] Query. |
Date: |
Wed, 26 Aug 2015 05:22:21 +0000 |
portCHAR server_address[] = "192.168.0.4";
#define PORT 100
int main( void )
{
struct sockaddr_in stServeurSockAddr;
portLONG lRetval;
portLONG lSocket = -1;
// 1) Configure system clocks.
sysclk_init();
// 2) Setup the GPIO in output for the board's LED.
vParTestInitialise();
// 3) Start Display task.
vDisplay_Start(display_TASK_PRIORITY);
// 4) Start the LED flash tasks just to provide visual feedback that the
// demo is executing.
vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
// 5) Start the ethernet tasks.
//vStartEthernetTaskLauncher( configMAX_PRIORITIES );
memset(&stServeurSockAddr, 0, sizeof(stServeurSockAddr));
stServeurSockAddr.sin_len = sizeof(stServeurSockAddr);
stServeurSockAddr.sin_addr.s_addr = inet_addr(server_address);
stServeurSockAddr.sin_port = htons(PORT);
stServeurSockAddr.sin_family = AF_INET;
// socket as a stream
lSocket= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if( lSocket == -1 )
{
// socket failed, blink a LED and stay here
for (;;) {
vParTestToggleLED( 2 );
vTaskDelay( 200 );
}
}
socklen_t xSize = sizeof( stServeurSockAddr );
if (bind(lSocket, (struct sockaddr *)&stServeurSockAddr,
sizeof(stServeurSockAddr)) < 0) {
// Problem setting up my end
close(lSocket);
return;
}
listen(lSocket,xBacklog);
for( ;; )
{
// xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient,
&xSize );
//configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
accept( lSocket, &stServeurSockAddr, &xSize );
}
recv( lSocket, cTempBuffer,sizeof(cTempBuffer),0);
}
Above code I need to run to implement simple TCP server, but everytime socket()
in main.c file returns -1, hence socket is not created.I need to solve this
problem.
Changes:
LWIP_PLATFORM_ASSERT(x) macro definition is commented in cc.h file. since its
a do-while() and results in deadlock suggested from ATmel people.
HTTP_USED ,SMTP_USED ,TFTP_USED macro are defined in FreeRTOSConfig.h file.
FREERTOS_USED defined in FreeRTOSConfig.h file ( to Create the task that
handles the MACB input packets.)
void *
#if !MEMP_OVERFLOW_CHECK
memp_malloc(memp_t type)
#else
memp_malloc_fn(memp_t type, const char* file, const int line)
#endif
{
struct memp *memp;
SYS_ARCH_DECL_PROTECT(old_level);
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
SYS_ARCH_PROTECT(old_level);
#if MEMP_OVERFLOW_CHECK >= 2
memp_overflow_check_all();
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
memp = memp_tab[type];
if (memp != NULL) {
memp_tab[type] = memp->next;
#if MEMP_OVERFLOW_CHECK
memp->next = NULL;
memp->file = file;
memp->line = line;
#endif /* MEMP_OVERFLOW_CHECK */
MEMP_STATS_INC_USED(used, type);
LWIP_ASSERT("memp_malloc: memp properly aligned",
((mem_ptr_t)memp % MEM_ALIGNMENT) == 0);
memp = (struct memp*)(void *)((u8_t*)memp + MEMP_SIZE);
} else {
LWIP_DEBUGF(MEMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("memp_malloc: out of memory
in pool %s\n", memp_desc[type]));
MEMP_STATS_INC(err, type);
}
SYS_ARCH_UNPROTECT(old_level);
return memp;
}
In the above code memp is always returned as null.
struct netconn*
netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
netconn_callback callback)
{
struct netconn *conn;
struct api_msg msg;
conn = netconn_alloc(t, callback);
if (conn != NULL) {
msg.function = do_newconn;
msg.msg.msg.n.proto = proto;
msg.msg.conn = conn;
if (TCPIP_APIMSG(&msg) != ERR_OK) {
LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL);
LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed));
LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox));
#if LWIP_TCP
LWIP_ASSERT("conn->acceptmbox shouldn't exist",
!sys_mbox_valid(&conn->acceptmbox));
#endif /* LWIP_TCP */
sys_sem_free(&conn->op_completed);
sys_mbox_free(&conn->recvmbox);
memp_free(MEMP_NETCONN, conn);
return NULL;
}
}
return conn;
}
In the above code conn is always returned as NULL.
Please let me know what can be done to resolve the Issue and implemnet EVK1105
as tcp server.
Thanks and Regards
Abhijith N.M.
---Disclaimer------------------------------ This e-mail contains PRIVILEGED AND
CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If
you are not the intended recipient, please notify the sender by e-mail and
delete the original message. Opinions, conclusions and other information in
this transmission that do not relate to the official business of QuEST Global
and/or its subsidiaries, shall be understood as neither given nor endorsed by
it. Any statements made herein that are tantamount to contractual obligations,
promises, claims or commitments shall not be binding on the Company unless
followed by written confirmation by an authorized signatory of the Company.
-----------------------------------------------------------------------------------
- [Savannah-users] Query.,
Abhijith N M <=