DDVSocket edits
This commit is contained in:
		
							parent
							
								
									8c6a315dfb
								
							
						
					
					
						commit
						a6311fe535
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		|  | @ -9,6 +9,7 @@ | |||
| #include <fcntl.h> | ||||
| 
 | ||||
| bool socketError = false; | ||||
| bool socketBlocking = false; | ||||
| 
 | ||||
| int DDV_OpenUnix(const char adres[], bool nonblock = false){ | ||||
|   int s = socket(AF_UNIX, SOCK_STREAM, 0); | ||||
|  | @ -67,11 +68,12 @@ int DDV_Accept(int sock, bool nonblock = false){ | |||
| 
 | ||||
| bool DDV_write(void * buffer, int todo, int sock){ | ||||
|   int sofar = 0; | ||||
|   socketBlocking = false; | ||||
|   while (sofar != todo){ | ||||
|     int r = send(sock, (char*)buffer + sofar, todo-sofar, 0); | ||||
|     if (r <= 0){ | ||||
|       switch (errno){ | ||||
|         case EWOULDBLOCK: printf("Would block\n"); break; | ||||
|         case EWOULDBLOCK: printf("Would block\n"); socketBlocking = true; break; | ||||
|         default: | ||||
|           socketError = true; | ||||
|           printf("Could not write! %s\n", strerror(errno)); | ||||
|  | @ -86,11 +88,12 @@ bool DDV_write(void * buffer, int todo, int sock){ | |||
| 
 | ||||
| bool DDV_read(void * buffer, int todo, int sock){ | ||||
|   int sofar = 0; | ||||
|   socketBlocking = false; | ||||
|   while (sofar != todo){ | ||||
|     int r = recv(sock, (char*)buffer + sofar, todo-sofar, 0); | ||||
|     if (r <= 0){ | ||||
|       switch (errno){ | ||||
|         case EWOULDBLOCK: printf("Read: Would block\n"); break; | ||||
|         case EWOULDBLOCK: printf("Read: Would block\n"); socketBlocking = true; break; | ||||
|         default: | ||||
|           socketError = true; | ||||
|           printf("Could not read! %s\n", strerror(errno)); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma