LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-23-2005, 05:55 PM   #1
mar1n
LQ Newbie
 
Registered: Dec 2005
Posts: 1

Rep: Reputation: Disabled
pftp-init-client.c


Hey already configured pftpfxp-v0.11.4mew6 and im trying to setup pftpfxp-autoconnect as well and it almost work but in this dir there is 3 files but for the scripts im using pftp-daemon.pl and cfg file but there is as well pftp-init-client.c but im dont know what for this file is :x please help

here is pftp-init-client.c code
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h> /* memset() */
#include <sys/time.h> /* select() */ 

#define REMOTE_SERVER_PORT 1234
#define REMOTE_PASSWORD "password"
#define MAX_MSG 100

int main(int argc, char *argv[]) {
  
  int sd, rc, i;
  struct sockaddr_in cliAddr, remoteServAddr;
  struct hostent *h;
  char buf[1024];

  /* check command line args */
  if(argc<3) {
    printf("usage : %s <server> <release>\n", argv[0]);
    exit(1);
  }

  /* get server IP address (no check if input is IP address or DNS name */
  h = gethostbyname(argv[1]);
  if(h==NULL) {
    printf("%s: unknown host '%s' \n", argv[0], argv[1]);
    exit(1);
  }

  printf("%s: sending data to '%s' (IP : %s) \n", argv[0], h->h_name,
	 inet_ntoa(*(struct in_addr *)h->h_addr_list[0]));

  remoteServAddr.sin_family = h->h_addrtype;
  memcpy((char *) &remoteServAddr.sin_addr.s_addr, 
	 h->h_addr_list[0], h->h_length);
  remoteServAddr.sin_port = htons(REMOTE_SERVER_PORT);

  /* socket creation */
  sd = socket(AF_INET,SOCK_DGRAM,0);
  if(sd<0) {
    printf("%s: cannot open socket \n",argv[0]);
    exit(1);
  }
  
  /* bind any port */
  cliAddr.sin_family = AF_INET;
  cliAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  cliAddr.sin_port = htons(0);
  
  rc = bind(sd, (struct sockaddr *) &cliAddr, sizeof(cliAddr));
  if(rc<0) {
    printf("%s: cannot bind port\n", argv[0]);
    exit(1);
  }

  sprintf(buf, "%s %s", REMOTE_PASSWORD, argv[2]);
  /* send data */
    rc = sendto(sd, buf, strlen(buf)+1, 0, 
		(struct sockaddr *) &remoteServAddr, 
		sizeof(remoteServAddr));

    if(rc<0) {
      printf("%s: cannot send data %d \n",argv[0],i-1);
      close(sd);
      exit(1);
    }
  
  return 1;
}
im have errors when executing this file :x
please tell me what does this file doing and im need to set this file up to work with the pftp-daemon.pl ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PFTP help (how to add sites and more) Jimichel Linux - Software 1 04-16-2005 08:41 AM
Pftp Mew timerx Linux - Newbie 0 12-05-2004 11:52 AM
PFTP -Mew himsa Linux - Newbie 6 04-07-2004 06:23 AM
PFTP-Mew Sebboh Linux - Software 0 03-22-2004 10:53 AM
pftp - can't compile owl123 Linux - Newbie 4 08-02-2003 11:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration