log send, sendrec, recv and notify system calls


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers log send, sendrec, recv and notify system calls
# 1  
Old 02-04-2008
log send, sendrec, recv and notify system calls

Hi,
I've a question about MINIX OS.

1 - I would like to log the messages that user or kernel process send to each other through the system call send, recv, sendrec and notify.
Since MINIX is a microkernel OS, I suppose that the best way is to have an TCP socket, listening in INADDR_ANY address. But, I don't know which port should I use. Can anyone help me?

2 - I've the following code:

Code:
int main(void)
{
	int sockfd, new_fd;  // listen on sock_fd, new connection on new_fd
	struct sockaddr_in my_addr;	// my address information
	struct sockaddr_in their_addr; // connector's address information
	socklen_t sin_size;
	struct sigaction sa;
	int yes=1;

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
		perror("socket");
		exit(1);
	}
(..)
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 = INADDR_ANY; // automatically fill with my IP
	memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);

	if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) == -1) {
		perror("bind");
		exit(1);
	}

(...)
}

But I get the error that, "Address family is not supported". I don't understand why?

Thanks,
Pedro
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A notify-send Question --

Greetings. I've come across a bit of a problem with notify-send syntax; and wondered if anyone out there had found a solution in the woodpile somewhere :) Here's the snippet which is giving me trouble:notify-send 'Text to display' image_data 300, 300, , , , , /etc/image.pngOutput:Invalid... (0 Replies)
Discussion started by: LinQ
0 Replies

2. Shell Programming and Scripting

[linux] tail2notify - script interface between tail -f + grep and notify-send

This isn't exactly a question. Just thought I'd share something I just wrote and found useful. For those of you on modern linux boxen: you may be aware that there's a lovely little tool called notify-send that you can use to send notifications to the desktop. Any experienced shell-scripter could... (0 Replies)
Discussion started by: ryran
0 Replies

3. UNIX for Dummies Questions & Answers

system calls in C

Hello, how would i be able to call ps in C programming? thanks, ---------- Post updated at 01:39 AM ---------- Previous update was at 01:31 AM ---------- here's the complete system call, ps -o pid -p %d, getpit() (2 Replies)
Discussion started by: l flipboi l
2 Replies

4. Shell Programming and Scripting

notify-send does not notify real time

Hi, I am having a little trouble getting notify-send to work the way I would like it to. I am using ubuntu - karmic koala 2.6.31-19-generic #56-Ubuntu SMP So here's the problem run the following commands one after the other. notify-send -i info -t 100000 -- "Hi" "world" & notify-send -i... (3 Replies)
Discussion started by: linuxpenguin
3 Replies

5. Programming

ABOUT RECV() SYSTEM CALL (regarding timer)

Hi all, I am facing a problem in recv() system call i.e.. in my project i have to implement timer for sending (data) and resending purpose when there is no acknowledgement. is there any way that recv() sys call has its own timer i.e., for ex: recv() has to wait for 10 secs. if any... (0 Replies)
Discussion started by: Rohil
0 Replies

6. Programming

System calls

why user is not able to switch from user to kernel mode by writing the function whose code is identical to system call. (1 Reply)
Discussion started by: joshighanshyam
1 Replies

7. UNIX Desktop Questions & Answers

Using system calls

Hi, I'm new to UNIX system calls. Can someone share your knowledge as to how exactly system calls should be executed? Can they be typed like commands such as mkdir on the terminal itself? Also, are there any websites which will show me an example of the output to expect when a system call like... (1 Reply)
Discussion started by: ilavenil
1 Replies

8. Programming

UDP socket - can both client and server recv and send

Hi, Am very new to socket programming. When we use UDP sockets to communicate between two processess, will both the client/server socket be able to send/recv ? meaning can sendto()/ recvfrom() be used on both server and client? It could be useful even if anybody provide some link on socket... (1 Reply)
Discussion started by: rvan
1 Replies

9. Programming

send and recv ARP package in AS3.0

In attachment, is the code to test IP by ARP proxy. I always use it to test a IP already existing in my cluster. Usage: arp_func eth0 192.168.1.1 Enviroment: IA64, RedHat AS3.0, 2.4.21-15.EL, gcc-3.2.3-34, "gcc -o arp_func arp_func.c" When the code below added before... (0 Replies)
Discussion started by: lameryang
0 Replies

10. UNIX for Dummies Questions & Answers

System calls for cp and mv

Which system calls are made for operations cp and mv (2 Replies)
Discussion started by: gaurava99
2 Replies
Login or Register to Ask a Question
send(2) 							System Calls Manual							   send(2)

Name
       send, sendto, sendmsg - send a message from a socket

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

       cc = send(s, msg, len, flags)
       int cc, s;
       char *msg;
       int len, flags;

       cc = sendto(s, msg, len, flags, to, tolen)
       int cc, s;
       char *msg;
       int len, flags;
       struct sockaddr *to;
       int tolen;

       cc = sendmsg(s, msg, flags)
       int cc, s;
       struct msghdr msg[];
       int flags;

Description
       The  and system calls are used to transmit a message to another socket.	The system call may be used only when the socket is in a connected
       state, while the and system calls may be used at any time.

       The address of the target is given by to, with tolen specifying its size.  The length of the message is given by len.  If  the  message	is
       too  long  to  pass atomically through the underlying protocol, the error EMSGSIZE is returned, and the message is not transmitted.  If the
       address specified in the argument is a broadcast address, the SO_BROADCAST option must be set for broadcasting to succeed.

       No indication of failure to deliver is implicit in a Return values of -1 indicate some locally detected errors.

       If no messages space is available at the socket to hold the message to be transmitted, normally blocks, unless the socket has  been  placed
       in nonblocking I/O mode.  The call can be used to determine when it is possible to send more data.

       The flags parameter can be set to MSG_OOB to send out-of-band data on sockets that support this features (for example, SOCK_STREAM).

       See for a description of the msghdr structure.

       The call returns the number of characters sent, or -1 if an error occurred.

Diagnostics
       [EBADF]		   An invalid descriptor was specified.

       [EDESTADDRREQ]	   A required address was omitted from an operation on a socket.

       [EFAULT] 	   An invalid user space address was specified for a parameter.

       [EINVAL] 	   An invalid argument length for the message was specified.

       [EINTR]		   The send was interrupted by delivery of a signal.

       [ENOTCONN]	   The socket is not connected.

       [ENOTSOCK]	   The argument s is not a socket.

       [EMSGSIZE]	   The socket requires that messages be sent atomically, and the size of the message to be sent made this impossible.

       [EPIPE]		   A write on a pipe or socket for which there is no process to read the data.

       [EWOULDBLOCK]	   The socket is marked nonblocking, and the requested operation would block.

See Also
       recv(2), getsockopt(2), socket(2)

																	   send(2)