ObjFW  Diff

Differences From Artifact [5a2d407327]:

To Artifact [4e13070b06]:


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#endif
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"

#import "OFBindFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotConnectedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"

#import "socket.h"
#import "socket_helpers.h"
#import "resolver.h"







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#endif
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"

#import "OFBindFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"

#import "socket.h"
#import "socket_helpers.h"
#import "resolver.h"
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
- (size_t)receiveIntoBuffer: (void*)buffer
		     length: (size_t)length
		     sender: (of_udp_socket_address_t*)sender
{
	ssize_t ret;

	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];

	sender->length = (socklen_t)sizeof(sender->address);

#ifndef _WIN32
	if ((ret = recvfrom(_socket, buffer, length, 0,
	    (struct sockaddr*)&sender->address, &sender->length)) < 0)
		@throw [OFReadFailedException







|







467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
- (size_t)receiveIntoBuffer: (void*)buffer
		     length: (size_t)length
		     sender: (of_udp_socket_address_t*)sender
{
	ssize_t ret;

	if (_socket == INVALID_SOCKET)
		@throw [OFNotOpenException exceptionWithObject: self];

	sender->length = (socklen_t)sizeof(sender->address);

#ifndef _WIN32
	if ((ret = recvfrom(_socket, buffer, length, 0,
	    (struct sockaddr*)&sender->address, &sender->length)) < 0)
		@throw [OFReadFailedException
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
#endif

- (void)sendBuffer: (const void*)buffer
	    length: (size_t)length
	  receiver: (of_udp_socket_address_t*)receiver
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];

#ifndef _WIN32
	if (sendto(_socket, buffer, length, 0,
	    (struct sockaddr*)&receiver->address, receiver->length) < length)
		@throw [OFWriteFailedException
		    exceptionWithObject: self
			requestedLength: length







|







522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
#endif

- (void)sendBuffer: (const void*)buffer
	    length: (size_t)length
	  receiver: (of_udp_socket_address_t*)receiver
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotOpenException exceptionWithObject: self];

#ifndef _WIN32
	if (sendto(_socket, buffer, length, 0,
	    (struct sockaddr*)&receiver->address, receiver->length) < length)
		@throw [OFWriteFailedException
		    exceptionWithObject: self
			requestedLength: length
582
583
584
585
586
587
588
589
590
591
592
593
594
	return (int)_socket;
#endif
}

- (void)close
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];

	close(_socket);
	_socket = INVALID_SOCKET;
}
@end







|





582
583
584
585
586
587
588
589
590
591
592
593
594
	return (int)_socket;
#endif
}

- (void)close
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotOpenException exceptionWithObject: self];

	close(_socket);
	_socket = INVALID_SOCKET;
}
@end