소켓프로그래밍 하는 중에 문제가 생겨서요.

ferozah의 이미지

안녕하세요. 오늘 소켓프로그래밍 책 받아서 열심히
코드 치고 따라하고 있는데 서버소스코드랑 클라이언트소스
코드랑 만들어서 gcc로 컴파일 시키려고 하니까 서버소스
코드는 잘 되는데 클라이언트소스 코드가 에러가 엄청나게
뜨더라구요. 책에 나온거 고대로 보고 했는데 도대체 뭐가
문제인지 잘 모르겠습니다. 이곳에서 도움을 받을 수 있지
않을까 해서 도움을 청해 봅니다^^

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#define MAXBUF 256
int main()
{
 int ssock;
 int clen;
 struct sockaddr_in server_addr;
 char buf[MAXBUF];

if((ssock=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    perror("socket error : ");
    exit(1);
 }

 clen = sizeof(server_addr);

 memset(&server_addr, 0, sizeof(server_addr));
 server_addr.sin_family = AF_INET;
 server_addr.sin_addr.s_addr = inet_addr(“127.0.0.1”);
 server_addr.sin_port = htons(3317);

 if(connect(ssock, (struct sockaddr *)&server_addr, clen) < 0){
   perror("connect error : ");
   exit(1);
 }

 memset(buf, 0, MAXBUF);

 if(read(ssock, buf, MAXBUF) <= 0){
  perror(“read error :");
  exit(1);
}
 close(ssock);

printf(“\n read : %s\n\n”, buf);

return 0;

 }

코드는 이렇구요. 에러메시지는
ike_client.c:30: error: stray ‘\226’ in program
like_client.c:30: error: stray ‘\128’ in program
like_client.c:30: error: stray ‘\156’ in program
like_client.c:30:45: error: too many decimal points in number
like_client.c:30: error: stray ‘\226’ in program
like_client.c:30: error: stray ‘\128’ in program
like_client.c:30: error: stray ‘\157’ in program
like_client.c:41: error: stray ‘\226’ in program
like_client.c:41: error: stray ‘\128’ in program
like_client.c:41: error: stray ‘\156’ in program
like_client.c:41: error: syntax error before ‘error’
like_client.c:41: error: missing terminating " character
like_client.c:45: warning: control reaches end of non-void function
like_client.c: At top level:
like_client.c:46: error: stray ‘\226’ in program
like_client.c:46: error: stray ‘\128’ in program
like_client.c:46: error: stray ‘\156’ in program
like_client.c:46: error: stray ‘\’ in program
like_client.c:46: error: syntax error before ‘read’
like_client.c:46: error: stray ‘\’ in program
like_client.c:46: error: stray ‘\’ in program
like_client.c:46: error: stray ‘\226’ in program
like_client.c:46: error: stray ‘\128’ in program
like_client.c:46: error: stray ‘\157’ in program
like_client.c:46: warning: type defaults to ‘int’ in declaration of ‘printf’
like_client.c:46: error: conflicting types for ‘printf’
like_client.c:46: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
like_client.c:46: warning: data definition has no type or storage class

이런게 뜨는데 도통 뭔지 모르겠습니다.
참고로 리눅스는 페도라 코어4입니다.
초보를 위해 도움 부탁드립니다~

superkkt의 이미지

소스 어디 다른 프로그램에서 복사해서 사용하신건가요? 에러나는 줄에 있는 쌍따옴표들이 이상하네요.. 지우고 새로 하니까 잘됩니다.

======================
BLOG : http://superkkt.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.