* sctp send and recv
@ 2009-09-17 23:29 colin wen
2009-09-21 13:45 ` Vlad Yasevich
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: colin wen @ 2009-09-17 23:29 UTC (permalink / raw)
To: linux-sctp
I wrote a simple sctp server and client to test sctp in linux.
after client call connect, server accept return a socket,
but after client call send(fd, "hello", 5, 0) server's recv call
does not return, server's recv return after client close and
re-connect to server.
I wonder if someone could tell me what's the problem.
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sctp send and recv
2009-09-17 23:29 sctp send and recv colin wen
@ 2009-09-21 13:45 ` Vlad Yasevich
2009-09-21 16:40 ` colin wen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2009-09-21 13:45 UTC (permalink / raw)
To: linux-sctp
colin wen wrote:
> I wrote a simple sctp server and client to test sctp in linux.
> after client call connect, server accept return a socket,
> but after client call send(fd, "hello", 5, 0) server's recv call
> does not return, server's recv return after client close and
> re-connect to server.
> I wonder if someone could tell me what's the problem.
> Thanks,
What kernel version are you using?
Can you post the source to your client and server?
-vlad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sctp send and recv
2009-09-17 23:29 sctp send and recv colin wen
2009-09-21 13:45 ` Vlad Yasevich
@ 2009-09-21 16:40 ` colin wen
2009-09-21 18:24 ` Vlad Yasevich
2009-09-21 22:00 ` colin wen
3 siblings, 0 replies; 5+ messages in thread
From: colin wen @ 2009-09-21 16:40 UTC (permalink / raw)
To: linux-sctp
On Mon, Sep 21, 2009 at 6:45 AM, Vlad Yasevich
<vladislav.yasevich@hp.com> wrote:
> colin wen wrote:
>> I wrote a simple sctp server and client to test sctp in linux.
>> after client call connect, server accept return a socket,
>> but after client call send(fd, "hello", 5, 0) server's recv call
>> does not return, server's recv return after client close and
>> re-connect to server.
>> I wonder if someone could tell me what's the problem.
>> Thanks,
>
>
> What kernel version are you using?
>
> Can you post the source to your client and server?
>
> -vlad
>
I am using 2.6.28-13-generic (debian-5.0) and also
tested the kernel 2.6.31 downloaded from kernel.org.
Please find the following test code.
Client:
------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <linux/in.h>
int main()
{
int fd;
struct sockaddr_in addr;
int len;
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if (fd < 0) {
printf("socket failed\n");
return -1;
}
printf("socket ok\n");
addr.sin_family = AF_INET;
addr.sin_port = htons(5060);
addr.sin_addr.s_addr = inet_addr("172.16.80.234");
if (connect(fd, (struct sockaddr*)&addr, sizeof addr)) {
printf("connect failed\n");
return -1;
}
printf("connect \n");
len = send(fd, "hello", 5, 0);
printf("send %d\n", len);
close(fd);
return 0;
}
Server:
--------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <linux/in.h>
int main()
{
int fd, fd_client;
struct sockaddr_in addr;
char buf[128];
int len;
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if (fd < 0) {
printf("socket failed\n");
return -1;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(5060);
addr.sin_addr.s_addr = INADDR_ANY;
if (bind(fd, (struct sockaddr*)&addr, sizeof addr)) {
printf("bind failed\n");
return -1;
}
if (listen(fd, 10)) {
printf("listen failed\n");
return -1;
}
while (1) {
len = sizeof(addr);
fd_client = accept(fd, (struct sockaddr*)&addr, &len);
if (fd_client < 0) {
printf("accept failed\n");
break;
}
printf("accept %d\n", fd_client);
while(1) {
len = recv(fd_client, buf, sizeof(buf), 0);
if (len <= 0)
break;
buf[len] = 0;
printf("%s\n", buf);
}
close(fd_client);
}
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sctp send and recv
2009-09-17 23:29 sctp send and recv colin wen
2009-09-21 13:45 ` Vlad Yasevich
2009-09-21 16:40 ` colin wen
@ 2009-09-21 18:24 ` Vlad Yasevich
2009-09-21 22:00 ` colin wen
3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2009-09-21 18:24 UTC (permalink / raw)
To: linux-sctp
colin wen wrote:
> On Mon, Sep 21, 2009 at 6:45 AM, Vlad Yasevich
> <vladislav.yasevich@hp.com> wrote:
>> colin wen wrote:
>>> I wrote a simple sctp server and client to test sctp in linux.
>>> after client call connect, server accept return a socket,
>>> but after client call send(fd, "hello", 5, 0) server's recv call
>>> does not return, server's recv return after client close and
>>> re-connect to server.
>>> I wonder if someone could tell me what's the problem.
>>> Thanks,
>>
>> What kernel version are you using?
>>
>> Can you post the source to your client and server?
>>
>> -vlad
>>
> I am using 2.6.28-13-generic (debian-5.0) and also
> tested the kernel 2.6.31 downloaded from kernel.org.
> Please find the following test code.
Ok. Just ran your server on a 2.6.31 kernel and it works perfectly fine.
I tried running on the same system as well as 2 different ones.
-vlad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sctp send and recv
2009-09-17 23:29 sctp send and recv colin wen
` (2 preceding siblings ...)
2009-09-21 18:24 ` Vlad Yasevich
@ 2009-09-21 22:00 ` colin wen
3 siblings, 0 replies; 5+ messages in thread
From: colin wen @ 2009-09-21 22:00 UTC (permalink / raw)
To: linux-sctp
On Mon, Sep 21, 2009 at 11:24 AM, Vlad Yasevich
<vladislav.yasevich@hp.com> wrote:
> colin wen wrote:
>> On Mon, Sep 21, 2009 at 6:45 AM, Vlad Yasevich
>> <vladislav.yasevich@hp.com> wrote:
>>> colin wen wrote:
>>>> I wrote a simple sctp server and client to test sctp in linux.
>>>> after client call connect, server accept return a socket,
>>>> but after client call send(fd, "hello", 5, 0) server's recv call
>>>> does not return, server's recv return after client close and
>>>> re-connect to server.
>>>> I wonder if someone could tell me what's the problem.
>>>> Thanks,
>>>
>>> What kernel version are you using?
>>>
>>> Can you post the source to your client and server?
>>>
>>> -vlad
>>>
>> I am using 2.6.28-13-generic (debian-5.0) and also
>> tested the kernel 2.6.31 downloaded from kernel.org.
>> Please find the following test code.
>
> Ok. Just ran your server on a 2.6.31 kernel and it works perfectly fine.
> I tried running on the same system as well as 2 different ones.
>
> -vlad
>
Yes, I found the current code is working fine too.
I had tested by using printf("%s", buf); which has no line break,
so did not output to my console, and I thought the recv call did not return.
sorry about that.
Thanks,
Colin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-09-21 22:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-17 23:29 sctp send and recv colin wen
2009-09-21 13:45 ` Vlad Yasevich
2009-09-21 16:40 ` colin wen
2009-09-21 18:24 ` Vlad Yasevich
2009-09-21 22:00 ` colin wen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).