-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c3505a
commit f398afa
Showing
3 changed files
with
41 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <stdio.h> | ||
|
||
main() | ||
{ | ||
int optlen, gs, socktype, s; | ||
|
||
/* Create a datagram socket. */ | ||
s = socket(AF_INET, SOCK_DGRAM, 0); | ||
if (s == -1) { | ||
perror("Socket not created"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* Ask for the socket type. */ | ||
optlen = sizeof(socktype); | ||
gs = getsockopt (s, SOL_SOCKET, SO_TYPE, &socktype, &optlen); | ||
if (gs == -1) { | ||
perror("getsockopt failed"); | ||
return EXIT_FAILURE; | ||
} | ||
/* Print socket type. */ | ||
switch (socktype) | ||
{ | ||
case SOCK_STREAM: | ||
puts("Stream socket.\n"); | ||
break; | ||
case SOCK_DGRAM: | ||
puts("Datagram socket.\n"); | ||
break; | ||
case SOCK_RAW: | ||
puts("Raw socket.\n"); | ||
break; | ||
default: | ||
puts("Unknown socket type.\n"); | ||
break; | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.