remove compile c with git
This commit is contained in:
parent
c2e16f5b83
commit
2d0f617768
1 changed files with 0 additions and 29 deletions
|
@ -1,29 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#define SERVER_SOCK_FILE "/tmp/udsserver.sock"
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
struct sockaddr_un server_addr = {};
|
|
||||||
server_addr.sun_family = AF_UNIX;
|
|
||||||
strcpy(server_addr.sun_path, SERVER_SOCK_FILE); // XXX: should be limited to about 104 characters, system dependent
|
|
||||||
|
|
||||||
// get socket
|
|
||||||
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
||||||
|
|
||||||
if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) > -1) {
|
|
||||||
unsigned char messageBuffer[500] = {};
|
|
||||||
const char* message = "Hello from C";
|
|
||||||
size_t messageLengthInBytes = strlen(message);
|
|
||||||
messageBuffer[0] = messageLengthInBytes;
|
|
||||||
// Lucky for us the message just happens to be compatible with UTF-8 encoding
|
|
||||||
strcpy((char *)messageBuffer+1, message);
|
|
||||||
send(sockfd, messageBuffer, messageLengthInBytes+1, 0);
|
|
||||||
} else {
|
|
||||||
perror("Unable to connect") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue