PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Noms de domaine > comp.protocols.tcp-ip > UDP from Windows to Linux
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.protocols.tcp-ip TCP and IP network protocols.

UDP from Windows to Linux

Réponse
 
LinkBack Outils de la discussion
Vieux 28/03/2006, 14h09   #1 (permalink)
Thoschi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut UDP from Windows to Linux

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
);
.......

  Réponse avec citation
Vieux 28/03/2006, 17h55   #2 (permalink)
Karsten Schulz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: UDP from Windows to Linux

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)



  Réponse avec citation
Vieux 28/03/2006, 17h57   #3 (permalink)
Rick Jones
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: UDP from Windows to Linux

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 for
sending 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...
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h35.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13882 seconds with 11 queries