tcp
-
Java - Network - File I/OJava 2018. 2. 7. 10:46
// Network를 통한 File I/O는// Socket을 통해서 주고 받는다 import java.io.BufferedInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileInputStream;import java.net.Socket; public class SenderMain { public static void main(String[] args) throws Exception { // 1. 경로 지정 String path = "D:/io/bang.gif"; File file = new File(path); // 2. 스트림 준비 FileInputStream fis = new FileInputStream..
-
Java - Network, MultiChatJava 2018. 2. 6. 10:29
import java.io.IOException;import java.net.Socket; public class MultiClient { public static void main(String[] args) throws IOException { Socket socket = null; // 1. 소켓 생성 + 2. 연결 요청 try { socket = new Socket("127.0.0.1", 9000); // 3. 할일 하기 + 스레드 생성 및 실행 System.out.println("연결 수락"); ClientSender sender = new ClientSender(socket); ClientReceiver receiver = new ClientReceiver(socket); sender.start..
-
Tcp/Ip_Lib_CC 2017. 12. 17. 20:44
#include #include #include #include #include #include #include #include /** 주소 정보가 IP address인지 domain명인지를 판단하기 위한 함수* IP address이면 1 그렇지 않으면 0을 return 함*/static int is_ipaddr(const char *addr){ while(*addr) { if(('0' h_length); } if((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { return -1; } if(connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_in)) == -1) { close(sock); r..