| 
									
										
										
										
											2009-02-17 12:28:43 -05:00
										 |  |  | USING: concurrency.combinators destructors fry | 
					
						
							| 
									
										
										
										
											2009-02-18 18:25:58 -05:00
										 |  |  | io.sockets kernel logging ;
 | 
					
						
							|  |  |  | IN: io.servers.packet | 
					
						
							| 
									
										
										
										
											2008-06-17 01:04:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | <PRIVATE
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LOG: received-datagram NOTICE | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : datagram-loop ( quot datagram -- )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         [ receive dup received-datagram [ swap call ] dip ] keep
 | 
					
						
							|  |  |  |         pick [ send ] [ 3drop ] if
 | 
					
						
							|  |  |  |     ] 2keep datagram-loop ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : spawn-datagrams ( quot addrspec -- )
 | 
					
						
							|  |  |  |     <datagram> [ datagram-loop ] with-disposal ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \ spawn-datagrams NOTICE add-input-logging | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PRIVATE>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : with-datagrams ( seq service quot -- )
 | 
					
						
							| 
									
										
										
										
											2008-09-10 23:11:40 -04:00
										 |  |  |     '[ [ [ _ ] dip spawn-datagrams ] parallel-each ] with-logging ; inline
 |