手机无线网络纸牌游戏源代码。非常适合学习使用

源代码在线查看: sender.java

软件大小: 354 K
上传用户: dounob
关键词: 手机 无线网络 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Sender.java
				//
				// Copyright (c) 2000-2001 Symbian Ltd. All rights reserved
				
				package com.symbian.devnet.whist.tokenRing;
				
				import javax.net.datagram.*;
				import java.io.*;
				
				/**
				 * A class responsible for initialising as DatagramService to be 
				 * used for sending Datagrams and for using it to send 
				 * Datagrams.
				 * @author Symbian Devnet
				 */ 
				class Sender
				{ 
					/**
					 * The DatagramService through which 
					 * Datagrams are sent. 
					 */
					private DatagramService senderService;		
				
					/** 
					 * Constructor which initialises the DatagramService.
					 * @param a 	the Address the DatagramService is
					 * 				initislised on.
					 */
					Sender(Address a) throws Exception
					{
						try
						{
							senderService = DatagramService.getServerService(a);
						}
						catch(Exception e)
						{
							System.out.println("Unable to getServerService.");
							System.exit(0);
						}
					}
					
					/**
					 * A method allowing Datagrams to be sent using the 
					 * DatagramService.
					 * @param dg the Datagram to be sent
					 */
					public void sendToken(Datagram dg) throws Exception
					{
						try
						{
							senderService.send(dg);			
						}
						catch(Exception e)
						{
							System.out.println("Address not supported.");
							System.exit(0);
						}	
					}
				}
						
				
										

相关资源