[ECOS] Can't connect properly (TCP/IP)
EXTERNAL Gladis Olaf (Praktikant; CR/AEM)
external.Olaf.Gladis@de.bosch.com
Wed Oct 31 15:47:00 GMT 2007
Hello,
I have a problem using TCP/IP Stack.
I am programming on a system, called NODE<MPC5200> and there is ecos
installed (with redboot).
My Ethernetdevice is Intel(r) LXT971A, but this should not be the
problem because I can flash
the device via TFTP.
I used nearly to 100% the code from the tests tcp_lo_test.c (from the
client part)
http://exr.lunn.ch/http/source/packages/net/common/current/tests/tcp_lo_
test.c
Here it is:
#include <network.h>
...
int Tcp_connectToServer()
{
int sock;
int n;
struct sockaddr_in serv_addr;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
//Error while open socket
return -1; //TODO return types
}
memset(&serv_addr,0,sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(0xC0A85001);
//192.168.80.1
serv_addr.sin_port = htons(TCP_MAIN_PORT); //5000
serv_addr.sin_len = sizeof(serv_addr);
n=connect(sock,(struct sockaddr
*)&serv_addr,sizeof(serv_addr));
if (n < 0)
{
//Connecting Error
return -1;
}
n=0;
n = write(sock,"testcase",strlen("testcase"));
if (n < 0)
{
//writing error
return -1;
}
return 0;
}
My server is a small python script:
import SocketServer
d=''
class EchoRequestHandler(SocketServer.BaseRequestHandler ):
def setup(self):
print self.client_address, 'connected!'
def handle(self):
global d
while 1:
try:
data = self.request.recv(1024)
d = d+data
if len(data) > 0:
print data,
if len(d) >= 3:
if d.strip()[-3:] == 'bye':
print "C Ya"
return
except:
print 'something go wrong'
return
def finish(self):
print self.client_address, 'disconnected!'
return
#server host is a tuple ('host', port)
print "start"
server = SocketServer.ThreadingTCPServer(('', 5000),
EchoRequestHandler)
server.serve_forever()
When I compile this code, except the line "serv_addr.sin_len =
sizeof(serv_addr);", with cygwin and run it under windows, it run
correct. But when I compile it for the Node, there it stop the execution
after the connect statement. But my "server" print the IP adress of the
node and the port and say that the connection has been established. Now
I don't know what i did wrong. Has anyone an idea what i can try?
Thank you in advance.
Olaf Gladis
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list