@@ -482,7 +482,7 @@ fn inet_ntop[
482
482
* Reference: https://man7.org/linux/man-pages/man3/inet_ntop.3p.html.
483
483
"""
484
484
constrained[
485
- int (address_family) in [AF_INET , AF_INET6 ], " Address family must be either INET_ADDRSTRLEN or INET6_ADDRSTRLEN."
485
+ Int (address_family) in [AF_INET , AF_INET6 ], " Address family must be either INET_ADDRSTRLEN or INET6_ADDRSTRLEN."
486
486
]()
487
487
constrained[
488
488
address_length in [INET_ADDRSTRLEN , INET6_ADDRSTRLEN ],
@@ -511,7 +511,7 @@ fn inet_ntop[
511
511
" address."
512
512
)
513
513
else :
514
- raise Error(" inet_ntop Error: An error occurred while converting the address. Error code: " + str (errno))
514
+ raise Error(" inet_ntop Error: An error occurred while converting the address. Error code: " + String (errno))
515
515
516
516
# We want the string representation of the address, so it's ok to take ownership of the pointer here.
517
517
return dst
@@ -573,7 +573,7 @@ fn inet_pton[address_family: Int32](src: UnsafePointer[c_char]) raises -> c_uint
573
573
* Reference: https://man7.org/linux/man-pages/man3/inet_ntop.3p.html
574
574
* This function is valid for `AF_INET` and `AF_INET6`.
575
575
"""
576
- constrained[int (address_family) in [AF_INET , AF_INET6 ], " Address family must be either AF_INET or AF_INET6." ]()
576
+ constrained[Int (address_family) in [AF_INET , AF_INET6 ], " Address family must be either AF_INET or AF_INET6." ]()
577
577
var ip_buffer : UnsafePointer[c_void]
578
578
579
579
@parameter
@@ -587,7 +587,7 @@ fn inet_pton[address_family: Int32](src: UnsafePointer[c_char]) raises -> c_uint
587
587
raise Error(" inet_pton Error: The input is not a valid address." )
588
588
elif result == - 1 :
589
589
var errno = get_errno()
590
- raise Error(" inet_pton Error: An error occurred while converting the address. Error code: " + str (errno))
590
+ raise Error(" inet_pton Error: An error occurred while converting the address. Error code: " + String (errno))
591
591
592
592
return ip_buffer.bitcast[c_uint]().take_pointee()
593
593
@@ -664,7 +664,7 @@ fn socket(domain: c_int, type: c_int, protocol: c_int) raises -> c_int:
664
664
raise Error(
665
665
" SocketError (ENFILE): The system-wide limit on the total number of open files has been reached."
666
666
)
667
- elif int (errno) in [ENOBUFS , ENOMEM ]:
667
+ elif Int (errno) in [ENOBUFS , ENOMEM ]:
668
668
raise Error(
669
669
" SocketError (ENOBUFS or ENOMEM): Insufficient memory is available. The socket cannot be created until"
670
670
" sufficient resources are freed."
@@ -675,7 +675,7 @@ fn socket(domain: c_int, type: c_int, protocol: c_int) raises -> c_int:
675
675
" this domain."
676
676
)
677
677
else :
678
- raise Error(" SocketError: An error occurred while creating the socket. Error code: " + str (errno))
678
+ raise Error(" SocketError: An error occurred while creating the socket. Error code: " + String (errno))
679
679
680
680
return fd
681
681
@@ -766,7 +766,7 @@ fn setsockopt(
766
766
elif errno == ENOTSOCK :
767
767
raise Error(" setsockopt: The argument `socket` is not a socket." )
768
768
else :
769
- raise Error(" setsockopt: An error occurred while setting the socket option. Error code: " + str (errno))
769
+ raise Error(" setsockopt: An error occurred while setting the socket option. Error code: " + String (errno))
770
770
771
771
772
772
fn _getsockopt [
@@ -858,7 +858,7 @@ fn getsockopt(
858
858
elif errno == ENOTSOCK :
859
859
raise Error(" getsockopt: The argument `socket` is not a socket." )
860
860
else :
861
- raise Error(" getsockopt: An error occurred while setting the socket option. Error code: " + str (errno))
861
+ raise Error(" getsockopt: An error occurred while setting the socket option. Error code: " + String (errno))
862
862
863
863
return option_value.bitcast[Int]().take_pointee()
864
864
@@ -935,7 +935,7 @@ fn getsockname[
935
935
elif errno == ENOTSOCK :
936
936
raise Error(" getsockname: The argument `socket` is not a socket, it is a file." )
937
937
else :
938
- raise Error(" getsockname: An error occurred while getting the socket name. Error code: " + str (errno))
938
+ raise Error(" getsockname: An error occurred while getting the socket name. Error code: " + String (errno))
939
939
940
940
941
941
fn _getpeername [
@@ -1010,7 +1010,7 @@ fn getpeername(file_descriptor: c_int) raises -> sockaddr_in:
1010
1010
elif errno == ENOTSOCK :
1011
1011
raise Error(" getpeername: The argument `socket` is not a socket, it is a file." )
1012
1012
else :
1013
- raise Error(" getpeername: An error occurred while getting the socket name. Error code: " + str (errno))
1013
+ raise Error(" getpeername: An error occurred while getting the socket name. Error code: " + String (errno))
1014
1014
1015
1015
# Cast sockaddr struct to sockaddr_in
1016
1016
return remote_address.bitcast[sockaddr_in]().take_pointee()
@@ -1110,7 +1110,7 @@ fn bind(socket: c_int, mut address: sockaddr_in) raises:
1110
1110
# elif errno == EROFS:
1111
1111
# raise Error("bind: The socket inode would reside on a read-only file system.")
1112
1112
1113
- raise Error(" bind: An error occurred while binding the socket. Error code: " + str (errno))
1113
+ raise Error(" bind: An error occurred while binding the socket. Error code: " + String (errno))
1114
1114
1115
1115
1116
1116
fn _listen (socket : c_int, backlog : c_int) -> c_int:
@@ -1168,7 +1168,7 @@ fn listen(socket: c_int, backlog: c_int) raises:
1168
1168
elif errno == EOPNOTSUPP :
1169
1169
raise Error(" listen: The socket is not of a type that supports the `listen()` operation." )
1170
1170
else :
1171
- raise Error(" listen: An error occurred while listening on the socket. Error code: " + str (errno))
1171
+ raise Error(" listen: An error occurred while listening on the socket. Error code: " + String (errno))
1172
1172
1173
1173
1174
1174
fn _accept [
@@ -1233,7 +1233,7 @@ fn accept(socket: c_int) raises -> c_int:
1233
1233
var result = _accept(socket, Pointer.address_of(remote_address), Pointer.address_of(socklen_t(sizeof[socklen_t]())))
1234
1234
if result == - 1 :
1235
1235
var errno = get_errno()
1236
- if int (errno) in [EAGAIN , EWOULDBLOCK ]:
1236
+ if Int (errno) in [EAGAIN , EWOULDBLOCK ]:
1237
1237
raise Error(
1238
1238
" accept: The socket is marked nonblocking and no connections are present to be accepted. POSIX.1-2001"
1239
1239
" allows either error to be returned for this case, and does not require these constants to have the"
@@ -1258,7 +1258,7 @@ fn accept(socket: c_int) raises -> c_int:
1258
1258
raise Error(" accept: The per-process limit of open file descriptors has been reached." )
1259
1259
elif errno == ENFILE :
1260
1260
raise Error(" accept: The system limit on the total number of open files has been reached." )
1261
- elif int (errno) in [ENOBUFS , ENOMEM ]:
1261
+ elif Int (errno) in [ENOBUFS , ENOMEM ]:
1262
1262
raise Error(
1263
1263
" accept: Not enough free memory. This often means that the memory allocation is limited by the socket"
1264
1264
" buffer limits, not by the system memory."
@@ -1274,7 +1274,7 @@ fn accept(socket: c_int) raises -> c_int:
1274
1274
if os_is_linux():
1275
1275
if errno == EPERM :
1276
1276
raise Error(" accept: Firewall rules forbid connection." )
1277
- raise Error(" accept: An error occurred while listening on the socket. Error code: " + str (errno))
1277
+ raise Error(" accept: An error occurred while listening on the socket. Error code: " + String (errno))
1278
1278
1279
1279
return result
1280
1280
@@ -1376,7 +1376,7 @@ fn connect(socket: c_int, address: sockaddr_in) raises:
1376
1376
" connect: Timeout while attempting connection. The server may be too busy to accept new connections."
1377
1377
)
1378
1378
else :
1379
- raise Error(" connect: An error occurred while connecting to the socket. Error code: " + str (errno))
1379
+ raise Error(" connect: An error occurred while connecting to the socket. Error code: " + String (errno))
1380
1380
1381
1381
1382
1382
fn _recv (
@@ -1442,7 +1442,7 @@ fn recv(
1442
1442
var result = _recv(socket, buffer, length, flags)
1443
1443
if result == - 1 :
1444
1444
var errno = get_errno()
1445
- if int (errno) in [EAGAIN , EWOULDBLOCK ]:
1445
+ if Int (errno) in [EAGAIN , EWOULDBLOCK ]:
1446
1446
raise Error(
1447
1447
" ReceiveError: The socket is marked nonblocking and the receive operation would block, or a receive"
1448
1448
" timeout had been set and the timeout expired before data was received."
@@ -1467,7 +1467,7 @@ fn recv(
1467
1467
else :
1468
1468
raise Error(
1469
1469
" ReceiveError: An error occurred while attempting to receive data from the socket. Error code: "
1470
- + str (errno)
1470
+ + String (errno)
1471
1471
)
1472
1472
1473
1473
return result
@@ -1560,7 +1560,7 @@ fn recvfrom(
1560
1560
var result = _recvfrom(socket, buffer, length, flags, address, Pointer[socklen_t].address_of(sizeof[sockaddr]()))
1561
1561
if result == - 1 :
1562
1562
var errno = get_errno()
1563
- if int (errno) in [EAGAIN , EWOULDBLOCK ]:
1563
+ if Int (errno) in [EAGAIN , EWOULDBLOCK ]:
1564
1564
raise " ReceiveError: The socket's file descriptor is marked `O_NONBLOCK` and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the socket's file descriptor is marked `O_NONBLOCK` or the socket does not support blocking to await out-of-band data."
1565
1565
elif errno == EBADF :
1566
1566
raise " ReceiveError: The socket argument is not a valid file descriptor."
@@ -1585,7 +1585,7 @@ fn recvfrom(
1585
1585
elif errno == ENOMEM :
1586
1586
raise " ReceiveError: Insufficient memory was available to fulfill the request."
1587
1587
else :
1588
- raise " ReceiveError: An error occurred while attempting to receive data from the socket. Error code: " + str (
1588
+ raise " ReceiveError: An error occurred while attempting to receive data from the socket. Error code: " + String (
1589
1589
errno
1590
1590
)
1591
1591
@@ -1657,7 +1657,7 @@ fn send(socket: c_int, buffer: UnsafePointer[c_void], length: c_size_t, flags: c
1657
1657
var result = _send(socket, buffer, length, flags)
1658
1658
if result == - 1 :
1659
1659
var errno = get_errno()
1660
- if int (errno) in [EAGAIN , EWOULDBLOCK ]:
1660
+ if Int (errno) in [EAGAIN , EWOULDBLOCK ]:
1661
1661
raise Error(
1662
1662
" SendError: The socket is marked nonblocking and the receive operation would block, or a receive"
1663
1663
" timeout had been set and the timeout expired before data was received."
@@ -1711,7 +1711,7 @@ fn send(socket: c_int, buffer: UnsafePointer[c_void], length: c_size_t, flags: c
1711
1711
else :
1712
1712
raise Error(
1713
1713
" SendError: An error occurred while attempting to receive data from the socket. Error code: "
1714
- + str (errno)
1714
+ + String (errno)
1715
1715
)
1716
1716
1717
1717
return result
@@ -1816,7 +1816,7 @@ fn sendto(
1816
1816
var errno = get_errno()
1817
1817
if errno == EAFNOSUPPORT :
1818
1818
raise " SendToError (EAFNOSUPPORT): Addresses in the specified address family cannot be used with this socket."
1819
- elif int (errno) in [EAGAIN , EWOULDBLOCK ]:
1819
+ elif Int (errno) in [EAGAIN , EWOULDBLOCK ]:
1820
1820
raise " SendToError (EAGAIN/EWOULDBLOCK): The socket's file descriptor is marked `O_NONBLOCK` and the requested operation would block."
1821
1821
elif errno == EBADF :
1822
1822
raise " SendToError (EBADF): The socket argument is not a valid file descriptor."
@@ -1857,7 +1857,7 @@ fn sendto(
1857
1857
elif errno == ENAMETOOLONG :
1858
1858
raise " SendToError (ENAMETOOLONG): The length of a pathname exceeds `PATH_MAX`, or pathname resolution of a symbolic link produced an intermediate result with a length that exceeds `PATH_MAX`."
1859
1859
else :
1860
- raise " SendToError: An error occurred while attempting to send data to the socket. Error code: " + str (
1860
+ raise " SendToError: An error occurred while attempting to send data to the socket. Error code: " + String (
1861
1861
errno
1862
1862
)
1863
1863
@@ -1927,7 +1927,7 @@ fn shutdown(socket: c_int, how: c_int) raises:
1927
1927
else :
1928
1928
raise Error(
1929
1929
" ShutdownError: An error occurred while attempting to receive data from the socket. Error code: "
1930
- + str (errno)
1930
+ + String (errno)
1931
1931
)
1932
1932
1933
1933
@@ -2016,10 +2016,10 @@ fn close(file_descriptor: c_int) raises:
2016
2016
raise CloseInterruptedError
2017
2017
elif errno == EIO :
2018
2018
raise CloseRWError
2019
- elif int (errno) in [ENOSPC , EDQUOT ]:
2019
+ elif Int (errno) in [ENOSPC , EDQUOT ]:
2020
2020
raise CloseOutOfSpaceError
2021
2021
else :
2022
- raise Error(" SocketError: An error occurred while creating the socket. Error code: " + str (errno))
2022
+ raise Error(" SocketError: An error occurred while creating the socket. Error code: " + String (errno))
2023
2023
2024
2024
2025
2025
fn get_errno () -> c_int:
0 commit comments