Menu

#6 using a different port then default port 2401 (:pserver:)

open
nobody
None
5
2004-01-13
2004-01-13
No

Hi guys,

in your class CSVServerConnection the DefaultPort is
hard-coded to 2401 (cvs standard port) and when
authenticating with 'pserver' there is following code:

tcpclient.Connect(repository.CvsRoot.Host, DEFAULT_PORT);

So it is not possible to connect on a different port
then 2401.

Is it possible to change this behaviour and let me
choose a port?

Best regards and thanx,
Ultra.

Discussion

  • Anonymous

    Anonymous - 2006-02-04

    Logged In: YES
    user_id=1443966

    Yes it is possible -D

    Do you want to do something like any port can be connected to?

     
  • Anonymous

    Anonymous - 2006-02-04

    Logged In: YES
    user_id=1443966

    my_addr.sin_port = htons(0);
    /* choose an unused port at random */

    my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    /* use my IP address */

    or, if you want to change the port to a specified port then
    use something like this:

    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>

    #define MYPORT 2401 /* CHANGE THIS */

    main()
    {
    int sockfd;
    struct sockaddr_in my_addr;

    sockfd = socket(AF_INET, SOCK_STREAM, 0); /* do some
    error checking! */

    my_addr.sin_family = AF_INET; /* host byte order */
    my_addr.sin_port = htons(MYPORT); /* short, network
    byte order */
    my_addr.sin_addr.s_addr = inet_addr("....");
    bzero(&(my_addr.sin_zero), 8); /* zero the rest
    of the struct */

    /* don't forget your error checking for bind(): */
    bind(sockfd, (struct sockaddr *)&my_addr,
    sizeof(struct sockaddr));
    .
    .
    .