Re: [1/5] 2.6.21-rc4: known regressions (v2)

Adrian Bunk
2007-03-25T12:22:06Z

[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]

On Sat, Mar 24, 2007 at 09:45:09PM -0700, David Miller wrote:
> From: Adrian Bunk <bunk@stusta.de>
> Date: Fri, 23 Mar 2007 19:48:17 +0100
>
> > Subject : problem with sockets
> > References : http://lkml.org/lkml/2007/3/21/248
> > Submitter : Jose Alberto Reguero <jareguero@telefonica.net>
> > Status : unknown
>
> Not enough information in his report, for example for the
> case he says does not work he fails to indicate what kernel
> or system type the Client runs on.
>
> Furthermore, his scripts don't even execute properly when
> I try to run them myself, for example server.py gives me
> this syntax error when python tries to parse the script:
>
> davem@sunset:~/src/GIT/net-2.6$ /usr/bin/python server.py
> File "server.py", line 9
> struct sockaddr_in ServerAddr;
> ^
> SyntaxError: invalid syntax
>
> Can someone help de-crapify this bug report?

He described one Python and one C example, and attached 2+2 programs.

The mailing list archive I quoted only contains the C files and doesn't
display the Python files with the error message
"unhandled content-type:application/x-python" - but that's not the fault
of the submitter, the bug report itself is OK.

I've attached all 4 files to this email.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

[-- Attachment #2: client.py --]
[-- Type: text/x-python, Size: 212 bytes --]

# Echo client program
import socket

mcast_adress = "227.234.253.9"
port = 15922

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.sendto('Hello, world', (mcast_adress, port))
s.close()

[-- Attachment #3: server.py --]
[-- Type: text/x-python, Size: 555 bytes --]

# Echo server program
import socket
import struct

HOST = '' # Symbolic name meaning the local host
PORT = 15922 # Arbitrary non-privileged port
mcast_adress = "227.234.253.9"

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
mreq = struct.pack('4si', socket.inet_aton(mcast_adress), socket.INADDR_ANY)
s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
data = s.recv(1024)
if (data):
print (data)
s.close()

[-- Attachment #4: client.c --]
[-- Type: text/x-csrc, Size: 499 bytes --]

#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>

main()
{
int sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in ClientAddr;
memset(&ClientAddr, 0, sizeof(ClientAddr));
ClientAddr.sin_family = AF_INET;
ClientAddr.sin_addr.s_addr = inet_addr("227.234.253.9");
int port = 15922;
ClientAddr.sin_port = htons((short) port);
char str[] = "Hello, world";
sendto(sock, str, strlen(str), 0, (struct sockaddr *)&ClientAddr, sizeof(ClientAddr));
close(sock);
}

[-- Attachment #5: server.c --]
[-- Type: text/x-csrc, Size: 1002 bytes --]

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <stdio.h>

main()
{
struct sockaddr_in ServerAddr;
int sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
int reuse = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int));
memset(&ServerAddr, 0, sizeof(ServerAddr));
ServerAddr.sin_family = AF_INET;
ServerAddr.sin_addr.s_addr = htonl(INADDR_ANY);
int port = 15922;
ServerAddr.sin_port = htons((short) port);
bind(sock, (struct sockaddr *)&ServerAddr, sizeof(ServerAddr));
struct ip_mreq mreq;
memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr.s_addr = inet_addr("227.234.253.9");
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
char str[100];
memset(&str, 0, sizeof(str));
recv(sock, str, 100, 0);
printf(":%s:\n", str);
close (sock);
}