Ipv6的封包傳輸 In Ubunto - Linux

Sandy avatar
By Sandy
at 2009-10-17T16:42

Table of Contents

#include <errno.h>
#include <error.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
int
main (int argc, char *argv[])
{
int result = 0;
struct addrinfo *ai;
struct addrinfo hints;
memset (&hints, '\0', sizeof(hints));
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;
int e = getaddrinfo (argv[1], "echo", &hints, &ai);
if(e != 0)
error (EXIT_FAILURE, 0, "getaddrinfo: %s", gai_strerror (e));
struct addrinfo *runp = ai;
while (runp !=NULL)
{
int sock = socket (runp->ai_family, runp->ai_socktype,
runp->ai_protocol);
if (sock != -1)
{

if(connect (sock, runp->ai_addr, runp->ai_addrlen) == 0)
{
char *line = NULL;
size_t len = 0;
ssize_t n = getline (&line, &len, stdin);
write (sock, line, len);
n = read (sock, line ,len);
write (STDOUT_FILENO, line, n);
close (sock);
goto out;
}
close (sock);
}
runp = runp->ai_next;
}
error (0, 0, "cannot contact %s", argv[1]);
result = 1;
out:
freeaddrinfo (ai);
return result;
}














這是我參考

http://people.redhat.com/drepper/userapi-ipv6.html

寫的

目前我是使用ubuntu 9.多版

我用過直接帶入參數 0 進

不過找不到位置

--
Tags: Linux

All Comments

fedora 8 上如何安裝 virtualbox?

Lucy avatar
By Lucy
at 2009-10-17T13:51
※ 引述《taskforce (taskforce)》之銘言: : 今天在 fedora 8 32bits 上安裝 virtualbox 3.0.8 : 我是下載 Fedora 8 (and#34;Werewolfand#34;) i386 : 但安裝好後點 virtualbox 都無反應 (也就是無法在後續 ...

Linux ubuntu9.04 是否有內建看圖軟體?

Eden avatar
By Eden
at 2009-10-17T02:21
因為晚輩有預定要買EDUBOOK來作文書用, 所以想先了解一下他預設的裝載作業系統Linux ubuntu。 但是晚輩GOOGLE了好久都沒有看到有人有說 Linux ubuntu 9.04 有內建看圖程式, 所以想來版上問一下是否有內建看圖程式? 如果有的話要起碼可以放大縮小圖片; 如果沒有的話可能就要下 ...

復製的用法

Kelly avatar
By Kelly
at 2009-10-17T01:01
請教一下: 我記得我在一本介紹作業系統的書上看到過 *nix的檔案系統中,可以在復製時先不真的把資料copy過去 等檔案更變時才寫入 可是我忘了實際的指令是什麼了 - ...

INIT:No inittab file found!

Linda avatar
By Linda
at 2009-10-16T22:48
目前遇上一個問題 在板上爬了一下文     大家都沒有什麼解決的辦法     倒是有位板友推文直接砍掉重練比較快     但是這當中有許多學校社團方面不願讓毀去的資料     所以想來請問板友們     我依正常開機程序打開主機     螢幕蹦出這兩句話     「INIT: No inittab f ...

fedora 8 上如何安裝 virtualbox?

Yedda avatar
By Yedda
at 2009-10-16T21:56
今天在 fedora 8 32bits 上安裝 virtualbox 3.0.8 我是下載 Fedora 8 (and#34;Werewolfand#34;) i386 但安裝好後點 virtualbox 都無反應 (也就是無法在後續選想要的系統 我想 xp virtual) 用指令的方式也無法成功 ...