Sponsored Content
Top Forums Programming writing a pipe with a c telnet Post 302182126 by era on Saturday 5th of April 2008 12:46:57 PM
Old 04-05-2008
Forking a telnet process just to read and write a network socket seems misdirected. You can open the socket straight from C and avoid the external processes altogether. Probably even simplifies your program (at the expense of having to figure out how to use sockets in C, but that's time well spent).
 

10 More Discussions You Might Find Interesting

1. Programming

pipe help

i made a lot of processes. here is the code: main() { printf("\nEnter K="); scanf("%d",&k); printf("Enter L="); scanf("%d",&l); printf("\nFather id=%d\n",getpid()); x=0; makechild(); sleep(2); return 1; } int makechild() { for(q=1;q<=k;q++) { if(f=fork()) { ... (5 Replies)
Discussion started by: bb666
5 Replies

2. UNIX for Dummies Questions & Answers

broken pipe?

Hi there, I try to use: > find * | ls but it just gave me one level of ' ls '. and it said: > find * | ls dir1 dir2 f1 f2 f3 Broken Pipe > what is broken pipe? how can i fix it? thks Gusla (3 Replies)
Discussion started by: gusla
3 Replies

3. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

4. Shell Programming and Scripting

How can I use pipe

Hi, guys: I am working on my shell using c. How can I use pipe to implement the following? ls -l 1>> | grep hellp 1<< 2>> | less 2<< (the output of ls goes to grep, and the output of grep goes to less) Thanks Please use and tags when posting code, data or logs etc. to preserve... (1 Reply)
Discussion started by: tomlee
1 Replies

5. Shell Programming and Scripting

Replace pipe with Broken Pipe

Hi All , Is there any way to replace the pipe ( | ) with the broken pipe (0xA6) in unix (1 Reply)
Discussion started by: saj
1 Replies

6. UNIX for Dummies Questions & Answers

Automatically login in the telnet from present telnet

Hi, I was writing one script which includes to switch to the another telnet automatically from the present telnet server. I was using rlogin but firstly it takes the same user name of the present telnet and secondly it is prompting for the password. But i want to switch to the another telnet... (2 Replies)
Discussion started by: Prateek
2 Replies

7. UNIX for Dummies Questions & Answers

xargs vs. pipe

I have been using unix on and off for a number of years. I am not a sys admin. I use what I need. I have googled this, but I really can't figure out what is the difference between using xarg and just using a regular pipe? Why do I need to include xarg sometimes and how do I know when I need it? (2 Replies)
Discussion started by: guessingo
2 Replies

8. UNIX for Dummies Questions & Answers

pipe > output

I can use pipe output to a file. For example ./somescript.sh > output.txt But for example if the output from ./somescript.sh is slow. like if it prints one line every minute then output.txt is not updated every minute. Lines are written to output.txt in one go, hence have to wait for the whole... (2 Replies)
Discussion started by: kevincobain2000
2 Replies

9. UNIX for Dummies Questions & Answers

Difference Between Krb5-telnet And Ekrb5-telnet

Hi, I want to know the difference between these two services. Both are under xinetd. Both are used for enabling and disabling Telnet service. So, can somebody please explain me the difference between the two ? Thanks in advance :) (0 Replies)
Discussion started by: kashifsd17
0 Replies

10. Shell Programming and Scripting

How to ignore Pipe in Pipe delimited file?

Hi guys, I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file for eg: file 1: xx|yy|"xyz|zzz"|zzz|12... using below awk command awk 'BEGIN {FS=OFS="|" } print $3 i would get xyz But i want as : xyz|zzz to consider as whole column... (13 Replies)
Discussion started by: rohit_shinez
13 Replies
NG_SOCKET(4)						   BSD Kernel Interfaces Manual 					      NG_SOCKET(4)

NAME
ng_socket -- netgraph socket node type SYNOPSIS
#include <sys/types.h> #include <netgraph/ng_socket.h> DESCRIPTION
A socket node is both a BSD socket and a netgraph node. The ng_socket node type allows user-mode processes to participate in the kernel netgraph(4) networking subsystem using the BSD socket interface. The process must have root privileges to be able to create netgraph sockets however once created, any process that has one may use it. A new ng_socket node is created by creating a new socket of type NG_CONTROL in the protocol family PF_NETGRAPH, using the socket(2) system call. Any control messages received by the node and not having a cookie value of NGM_SOCKET_COOKIE are received by the process, using recvfrom(2); the socket address argument is a struct sockaddr_ng containing the sender's netgraph address. Conversely, control messages can be sent to any node by calling sendto(2), supplying the recipient's address in a struct sockaddr_ng. The bind(2) system call may be used to assign a global netgraph name to the node. To transmit and receive netgraph data packets, a NG_DATA socket must also be created using socket(2) and associated with a ng_socket node. NG_DATA sockets do not automatically have nodes associated with them; they are bound to a specific node via the connect(2) system call. The address argument is the netgraph address of the ng_socket node already created. Once a data socket is associated with a node, any data pack- ets received by the node are read using recvfrom(2) and any packets to be sent out from the node are written using sendto(2). In the case of data sockets, the struct sockaddr_ng contains the name of the hook on which the data was received or should be sent. As a special case, to allow netgraph data sockets to be used as stdin or stdout on naive programs, a sendto(2) with a NULL sockaddr pointer, a send(2) or a write(2) will succeed in the case where there is exactly ONE hook attached to the socket node, (and thus the path is unambigu- ous). There is a user library that simplifies using netgraph sockets; see netgraph(3). HOOKS
This node type supports hooks with arbitrary names (as long as they are unique) and always accepts hook connection requests. CONTROL MESSAGES
This node type supports the generic control messages, plus the following: NGM_SOCK_CMD_NOLINGER When the last hook is removed from this node, it will shut down as if it had received a NGM_SHUTDOWN message. Attempts to access the sockets associated will return ENOTCONN. NGM_SOCK_CMD_LINGER This is the default mode. When the last hook is removed, the node will continue to exist, ready to accept new hooks until it is explic- itly shut down. All other messages with neither the NGM_SOCKET_COOKIE or NGM_GENERIC_COOKIE will be passed unaltered up the NG_CONTROL socket. SHUTDOWN
This node type shuts down and disappears when both the associated NG_CONTROL and NG_DATA sockets have been closed, or a NGM_SHUTDOWN control message is received. In the latter case, attempts to write to the still-open sockets will return ENOTCONN. If the NGM_SOCK_CMD_NOLINGER message has been received, closure of the last hook will also initiate a shutdown of the node. SEE ALSO
socket(2), netgraph(3), netgraph(4), ng_ksocket(4), ngctl(8) HISTORY
The ng_socket node type was implemented in FreeBSD 4.0. AUTHORS
Julian Elischer <julian@FreeBSD.org> BUGS
It is not possible to reject the connection of a hook, though any data received on that hook can certainly be ignored. The controlling process is not notified of all events that an in-kernel node would be notified of, e.g. a new hook, or hook removal. Some node-initiated messages should be defined for this purpose (to be sent up the control socket). BSD
January 19, 1999 BSD
All times are GMT -4. The time now is 06:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy