How to open and use a socket in C?

前端 未结 8 2039
生来不讨喜
生来不讨喜 2020-12-13 21:19

I would like to know the simplest and most effective way to open and write data to a socket in the C programming language for network programming.

相关标签:
8条回答
  • 2020-12-13 22:02

    You're right, using sockets in C has a difficult syntax. Later languages like Java and Python make it a snap by comparison. The best tutorial I've found for doing socket programming in C is Beej's Guide to Network Programming. I recommend you start at the beginning to get a good overview, but if you just need to get some code working now, you can skip ahead to the section titled Client-Server Background.

    Good luck!

    0 讨论(0)
  • 2020-12-13 22:05

    You don't mention what platform you are on, but a copy of Unix Network Programming by Stevens would be a good addition to your bookshelf. Most operating systems implement Berkley Sockets using socket, bind, connect, etc.

    0 讨论(0)
提交回复
热议问题