SocketDLL - Python Socket Library (C++ Based)
Python에서 사용하기 쉬운 고성능 C++ 소켓 라이브러리
특징
- C++ 기반으로 구현된 고성능 TCP 소켓 통신
- 사용하기 쉬운 Python 객체 지향 인터페이스
- 서버/클라이언트 모두 지원
- Windows 플랫폼 지원 (Linux, macOS 지원 예정)
설치
pip install socket-dll
빠른 시작
TCP 서버 예제
from socket_dll import TCPServer
# 서버 생성 및 시작
server = TCPServer(8080)
server.start()
print("[OK] 서버가 8080 포트에서 시작되었습니다")
try:
# 클라이언트 연결 대기
print("클라이언트 연결 대기 중...")
client = server.accept()
print("[OK] 클라이언트 연결됨")
# 데이터 수신
data = client.receive()
print(f"수신: {data.decode('utf-8')}")
# 응답 전송
client.send("Hello from server!")
client.close()
finally:
server.close()
TCP 클라이언트 예제
from socket_dll import TCPClient
# 서버에 연결
client = TCPClient(host="127.0.0.1", port=8080)
print("[OK] 서버에 연결되었습니다")
# 메시지 전송
client.send("Hello from client!")
print("[OK] 메시지 전송 완료")
# 응답 수신
response = client.receive()
print(f"서버 응답: {response.decode('utf-8')}")
client.close()
API 레퍼런스
TCPServer 클래스
TCP 서버를 생성하고 관리하는 클래스입니다.
server = TCPServer(port, dll_path=None)
매개변수:
port(int): 서버가 사용할 포트 번호dll_path(str, optional): DLL 파일 경로 (기본값: 자동 탐색)
메서드:
start(): 서버를 시작합니다accept(): 클라이언트 연결을 수락하고 TCPClient 객체를 반환합니다close(): 서버를 종료합니다
TCPClient 클래스
TCP 클라이언트를 생성하고 관리하는 클래스입니다.
client = TCPClient(host=None, port=None, dll_path=None)
매개변수:
host(str, optional): 연결할 서버 주소port(int, optional): 연결할 서버 포트dll_path(str, optional): DLL 파일 경로 (기본값: 자동 탐색)
메서드:
connect(host, port): 서버에 연결합니다send(data): 데이터를 전송합니다 (str 또는 bytes)receive(buffer_size=4096): 데이터를 수신합니다 (bytes 반환)close(): 연결을 종료합니다
SocketDLL 클래스
저수준 DLL 래퍼 클래스입니다. 고급 사용자용입니다.
from socket_dll import SocketDLL
dll = SocketDLL(dll_path=None)
전체 예제
에코 서버
from socket_dll import TCPServer
def echo_server(port=8080):
server = TCPServer(port)
server.start()
print(f"[OK] 에코 서버 시작 (포트: {port})")
try:
while True:
print("클라이언트 연결 대기...")
client = server.accept()
print("[OK] 클라이언트 연결됨")
try:
while True:
# 데이터 수신
data = client.receive()
if not data:
break
message = data.decode('utf-8')
print(f"수신: {message}")
# 에코 응답
client.send(f"Echo: {message}")
except Exception as e:
print(f"[ERROR] {e}")
finally:
client.close()
print("클라이언트 연결 종료")
except KeyboardInterrupt:
print("\n서버 종료 중...")
finally:
server.close()
if __name__ == "__main__":
echo_server()
멀티 메시지 클라이언트
from socket_dll import TCPClient
def chat_client(host="127.0.0.1", port=8080):
client = TCPClient(host=host, port=port)
print(f"[OK] {host}:{port}에 연결됨")
try:
while True:
# 사용자 입력
message = input("메시지 입력 (quit로 종료): ")
if message.lower() == 'quit':
break
# 전송
client.send(message)
# 응답 수신
response = client.receive()
print(f"서버: {response.decode('utf-8')}")
except Exception as e:
print(f"[ERROR] {e}")
finally:
client.close()
print("연결 종료")
if __name__ == "__main__":
chat_client()
에러 처리
from socket_dll import TCPServer
try:
server = TCPServer(8080)
server.start()
except Exception as e:
print(f"서버 시작 실패: {e}")
요구사항
- Python 3.7 이상
- Windows OS (현재 버전)
라이선스
MIT License
기여
버그 리포트나 기능 제안은 GitHub Issues를 이용해주세요.
변경 이력
0.1.0 (2025-11-03)
- 첫 릴리스
- TCP 서버/클라이언트 기능
- Windows 지원
Metadata
Release files for socket-dll-srchoi 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| socket_dll_srchoi-0.1.1.tar.gz | 23.4 kB | Without provenance | Details for socket_dll_srchoi-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| socket_dll_srchoi-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for socket_dll_srchoi-0.1.1-py3-none-any.whl |
Total release size: 44.3 kB
Release files / socket_dll_srchoi-0.1.1.tar.gz
| Download URL | socket_dll_srchoi-0.1.1.tar.gz |
|---|---|
| Size | 23.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5f96501236927e4ba437ba8768e60370d665ac66749151402f3645e93eec1cd
|
|
BLAKE2b-256 checksum How to use checksums |
570352909dd94809f2d21fb41183677ae572e8ecaff722ed316d17ebd6090b2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.4
|
Release files / socket_dll_srchoi-0.1.1-py3-none-any.whl
| Download URL | socket_dll_srchoi-0.1.1-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6d552b5c958be09691daef5b08d24e93618d8b0cc415634b33262f49521aec6
|
|
BLAKE2b-256 checksum How to use checksums |
5b30b76e345a529505dc65bb20491f0440b3c8211826002d1b5f6445305de6e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.4
|
Security for socket-dll-srchoi 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.