public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: kevin_lemay@agilent.com
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Problem Establishing socket Connection
Date: Mon, 10 Nov 2003 19:34:00 -0000	[thread overview]
Message-ID: <20031110193434.GI7282@lunn.ch> (raw)
In-Reply-To: <1BEBA5E8600DD4119A50009027AF54A010FAE459@axcs04.cos.agilent.com>

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

On Mon, Nov 10, 2003 at 11:12:30AM -0700, kevin_lemay@agilent.com wrote:

> I am trying to port some working vxWorks code over the eCos. This
> includes some standard BSD socket connections.

> I am encountering a problem within eCos. It has decided that I am
> trying to establish a network connection to a multicast socket,
> which is not the case.
> 
> We are attempting to connect to 130.30.174.109 (x821eae6d), port 5678.
> 
> I am using the CVS version of eCos as of Friday on an i386 platform.

It always a good idea to post a complete (none)working test
case. Something we can just compile and run. It saves us time messing
turning your code fragment into something useful.

I've attached what i used to test this.

> 
> The error occurs in tcp_usrrec.c at line 341
> 
> 
>  	336		/*
>  	337		 * Must disallow TCP ``connections'' to multicast addresses.
>  	338		 */
>  	339		sinp = (struct sockaddr_in *)nam;
> -	340		if (sinp->sin_family == AF_INET
> -	341		    && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
> -	342			error = EAFNOSUPPORT;
> -	343			goto out;
>  	344		}

I get another error. EINVAL. I didn't track it down, but these seems
much more reasonable to me than EAFNOSUPPORT.

Please try to reproduce your problem either using my code, or build a
complete test case which demonstrates the problem.

         Thanks
                Andrew

[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 2118 bytes --]

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

#include <cyg/infra/testcase.h>

#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
static char stack[STACK_SIZE];
static cyg_thread thread_data;
static cyg_handle_t thread_handle;

int yourtest(void) 
{
  
   int rc;
    struct sockaddr_in servAddr;
    int socketId;
    char * srvIpAddress = "130.30.174.109";
    int port = 5297;
    
    /* Server side */
    bzero(&servAddr, sizeof(servAddr));
    servAddr.sin_family = AF_INET;
    inet_aton(srvIpAddress, &servAddr.sin_addr);
    servAddr.sin_port = htons(port);
                                                                                                    
    /* create socket */
    socketId = socket(AF_INET, SOCK_STREAM, 0);
                                                                                                    
    if (socketId < 0)
    {
        return( -1 );
    }
                                                                                                    
    /* connect to server */
    rc = connect(socketId, (struct sockaddr *) &servAddr, sizeof(servAddr));
    if (rc<0)
    {
        close(socketId);
        socketId = 0;
        perror("connect");
        return(-1);
    }
    return(socketId);
    
}

void myfunc(cyg_addrword_t data)
{
                                                                                        
  init_all_network_interfaces();
  
  yourtest();
}

void
cyg_start(void)
{
    CYG_TEST_INIT();

    cyg_thread_create(3,                        // Priority
                      myfunc,                   // entry
                      0,                        // entry parameter
                      "Test program",           // Name
                      &stack[0],                // Stack
                      STACK_SIZE,               // Size
                      &thread_handle,           // Handle
                      &thread_data              // Thread data structure
            );
    cyg_thread_resume(thread_handle);    // Start it

    cyg_scheduler_start();
}




[-- Attachment #3: Type: text/plain, Size: 146 bytes --]

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

  reply	other threads:[~2003-11-10 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-10 18:15 kevin_lemay
2003-11-10 19:34 ` Andrew Lunn [this message]
2003-11-10 20:11 kevin_lemay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031110193434.GI7282@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=kevin_lemay@agilent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).