[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] Socket Programming






Vernard,


You know much about Win32 programming?


I need to sucessfully run this piece of UNIX OK code in winbloze
/* terminal.c
??*
??*?? Small program to allow running of an excutable 
??*
??*?? Arguments:
??*?????????? ?????????????? argv[1]: PORT to be input and output
??*?????????? ?????????????? argv[2]: Console application to execute on the serial port defined
??*
??*/
???? 
#include <fcntl.h>
#include <stdio.h>


int
main(int argc, char *argv[])
{
?????????????? ?????????????? int fd;


?????????????? ?????????????? /* check arguments */
?????????????? ?????????????? if(argc != 3)
?????????????? ?????????????? {
?????????????? ?????????????? ?????????????? printf("terminal [serial port] [command shell to execute]\n");
?????????????? ?????????????? ?????????????? exit(1);
?????????????? ?????????????? }


?????????????? ?????????????? 
?????????????? ?????????????? /* Open Serial Port */
?????????????? ?????????????? if((fd = open(argv[1], O_RDWR)) == -1)
?????????????? ?????????????? {
?????????????? ?????????????? ?????????????? perror("terminal: OPEN COM");
?????????????? ?????????????? ?????????????? exit(1);
?????????????? ?????????????? }


?????????????? ?????????????? 
?????????????? ?????????????? /* Set STDIN, STDOUT, STDERR to the serial port */
?????????????? ?????????????? dup2(fd, 0);
?????????????? ?????????????? dup2(fd, 1);
?????????????? ?????????????? dup2(fd, 2);


?????????????? ?????????????? /* Execute the command specified */
?????????????? ?????????????? execl(argv[2],argv[2], 0);
?????????????? ?????????????? 
?????????????? ?????????????? /* If we are here, there is an issue! */
?????????????? ?????????????? perror("terminal");


?????????????? ?????????????? return 1;
}


What happens:


cmd.exe comes across COM1.?? But, on terminal, I can not type anything and it
appears that cmd.exe has terminated.?? Sorry for the windows post.


Any help would be appreciated.


Thanks,
Chris




-----Original Message-----
From: Vernard Martin [mailto:vernard at cc.gatech.edu]
To: ale at ale.org
Sent: Tuesday, June 05, 2001 11:07 AM
To: Fulton Green
Cc: Terry Lee Tucker; ale at ale.org
Subject: Re: [ale] Socket Programming



> When I was learning sockets back in '98, I found the book _Beginning Linux
> Programming_ to be invaluable for a quick start. Then I got the _UNIX
> Network Programming_ book by Richard Stevens to go more in-depth.


By far the most in-depth book for doing any unix network programming is the
Stevens book. A must have book in my library.


V
-- 
Vernard Martin (vernard at cc.gatech.edu) http://www.cc.gatech.edu/~vernard/???????? 
?????????????? "Anything worth fighting over is worth fighting dirty over"
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.