|
|
|
|
||||||
| comp.protocols.tcp-ip TCP and IP network protocols. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi, (Win2000, VC++, SuSe 9.2)
I want to send UDP-telegramms from a Windows 2000 to a Linux PC. Port and Adresse ar OK, but the Linux Application didn't get it. Running tcp_dump on the Linux PC shows: IP 172.16.8.227 > 172.16.8.109: icmp 104: 172.16.8.109 udp port 3000 unreachable Something special between Windows- und Linux? Thanks, Thomas Send and Receive see below -------------------------------------------------------------------------------- void Win_Send() { WSADATA wsaData; SOCKET SendSocket; sockaddr_in RecvAddr; // Initialize Winsock err = WSAStartup(MAKEWORD(2,2), &wsaData); //--------------------------------------------- // Create a socket for sending data // SendSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); SendSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); //--------------------------------------------- // Set up the RecvAddr structure with the IP address of // the receiver (in this example case "123.456.789.1") // and the specified port number. RecvAddr.sin_family = AF_INET; RecvAddr.sin_port = htons(3000); RecvAddr.sin_addr.s_addr = inet_addr("172.16.8.227"); err = sendto(SendSocket, m_SendBuf, sizeof(m_SendBuf), 0, (SOCKADDR *) &RecvAddr, sizeof(RecvAddr)); ....... } ------------------------------------------------------------------------------------------------------ int Linux_Receive(int Port, int sendbuff, int rcvbuff, struct sockaddr_in &Write_address, struct sockaddr_in &Read_address, int &Sockit_ptr, char *Address, int bm_flag, char *DeviceAddress) { int on = 1; struct protoent *ppe; struct ip_mreq stMreq; Write_address.sin_family = AF_INET; Write_address.sin_port = htons(3000); ppe = getprotobyname("udp"); if (ppe == 0) { perror("Protocol udp unavailable??"); return(-1); } Sockit_ptr = socket(PF_INET, SOCK_DGRAM, ppe->p_proto); if (Sockit_ptr < 0) { perror("init_socket - Opening socket SOCK_DGRAM"); return(-1); } if (setsockopt(Sockit_ptr, SOL_SOCKET, SO_DONTROUTE, (char *) &on, sizeof(int)) < 0) { perror("init_socket - setsockopt SO_DONTROUTE"); } if (setsockopt(Sockit_ptr, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(int)) < 0) { perror("init_socket - setsockopt SO_REUSEADDR"); } if (setsockopt(Sockit_ptr, SOL_SOCKET, SO_SNDBUF, (char *)&sendbuff, sizeof(sendbuff)) < 0) { perror("init_socket - setsockopt SO_SNDBUF"); } if (setsockopt(Sockit_ptr, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbuff, sizeof(rcvbuff)) < 0) { perror("init_socket - setsockopt SO_RCVBUF"); } if (setsockopt(Sockit_ptr, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof(on)) < 0) { perror("init_socket - setsockopt SO_BROADCAST"); } Read_address.sin_family = AF_INET; Read_address.sin_addr.s_addr = inet_addr(Address); Write_address.sin_addr.s_addr = inet_addr(Address); Read_address.sin_port = htons(Port); int fl = sizeof(struct sockaddr_in); if (bind(Sockit_ptr,(struct sockaddr *) &(Read_address),fl) < 0) { close(Sockit_ptr); perror("init_socket - bind"); return(-1); } printf(" Broadcast Address %s\n",inet_ntoa(Write_address.sin_addr)); printf(" Read Address %s\n",inet_ntoa(Read_address.sin_addr)); #ifndef SPARC if (fcntl(Sockit_ptr,F_SETFL, FNDELAY) < 0) { #else if (fcntl(Sockit_ptr,F_SETFL, O_NDELAY) < 0) { #endif perror("init_socket - fcntl FNDELAY"); } void FSnd_read(void) { static char Buffer[3072]; char *source_ip = NULL; struct sockaddr_in addr; unsigned int length = sizeof(sockaddr_in); int BuffSize = 3072; int len len = recvfrom( Sockit_ptr, Buffer, BuffSize, 0, (struct sockaddr *) &addr, &length ); ....... |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Thoschi wrote:
I didn't read your code, but... > Running tcp_dump on the Linux PC shows: > IP 172.16.8.227 > 172.16.8.109: icmp 104: 172.16.8.109 udp port 3000 > unreachable > > Something special between Windows- und Linux? .... I guess you have to switch off the SuSE Linux paketfilter...?! Karsten (fu2p) |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Thoschi <tschindler2000@hotmail.com> wrote:
> Hi, (Win2000, VC++, SuSe 9.2) > I want to send UDP-telegramms from a Windows 2000 to a Linux PC. If you want to send telegrams I'd suggest Western Union, but alas, they stopped sending telegrams a while ago. Meanwhile, as forsending UDP datagrams: > Port and Adresse ar OK, but the Linux Application didn't get it. > Running tcp_dump on the Linux PC shows: > IP 172.16.8.227 > 172.16.8.109: icmp 104: 172.16.8.109 udp port 3000 > unreachable That suggests there was no socket open and bound to port 3000 on the linux system, perhaps one or more of the calls in your linux receiver didn't do quite what you expected it to - an strace of the application may see. When you are running the Linux receiver, can you see the socket in the output of netstat -an | grep 3000 ? Is there any firewall running on the Linux system? rick jones -- oxymoron n, Hummer H2 with California Save Our Coasts and Oceans plates these opinions are mine, all mine; HP might not want them anyway... ![]() feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH... |
|
![]() |
| Outils de la discussion | |
|
|